存储桶中不存在使用Google App Engine应用程序成功上传的图像文件 [英] Image file successfully uploaded using a Google App Engine application does not exist in bucket

查看:175
本文介绍了存储桶中不存在使用Google App Engine应用程序成功上传的图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

我使用CloudStorageTools :: createUploadUrl()方法创建特定于应用程序的上传URL,如下所示:

I create the application specific upload URL, using the method CloudStorageTools::createUploadUrl() as follows:

require_once 'google/appengine/api/cloud_storage  
/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;

$options = [ 'gs_bucket_name' => 'myuserpics' ];
$upload_url =  
CloudStorageTools::createUploadUrl('/upload_handler.php', $options);

我使用上面的URL作为我用来接受上传的表单的操作,如下所示:

I Use the above URL as the action for the form I use to accept uploads, as follows:

<form action="<?php echo $upload_url?>"  
enctype="multipart/form-data"   method="post">
    Files to upload: <br>
    <input type="file" name="uploaded_files" size="40">
    <input type="submit" value="Send">
</form>

以下是upload_handler.php的内容:

Below is the content of upload_handler.php:

<?php
    var_dump($_FILES);
?>

我在创建后的10分钟内开始上传到上面的URL并获得以下输出:

I start uploading to the above URL within 10 minutes of its creation and get the following output:

array(1) { 
    ["userfile"]=> array(5) { 
        ["name"]=> array(1) { 
            [0]=>   string(11) "fashion.jpg" 
        } 
        ["type"]=> array(1) { 
            [0]=> string(10) "image/jpeg" 
        } 
        ["tmp_name"]=> array(1) { 
            [0]=> string(200) "gs://myuserpics/***VERY LONG STRING***" 
        } 
        ["error"]=> array(1) { 
            [0]=> int(0) 
        } ["size"]=> array(1) { 
            [0]=> int(59527) 
        } 
    } 
} 

权限设置为存储桶myuserpics是默认权限。

The permissions set for the bucket "myuserpics" are the default permissions.

当我查看存储桶时,我看不到上传的图像。

When I look in the bucket, I do not see the uploaded image.

在Google Developers Console中,我可以上传图片,然后在存储桶中查看。但是,如果从应用程序上传图像,我无法在桶中看到它。我做错了什么?

From the Google Developers Console, I am able to upload an image and then see it in the bucket. However, if an image is uploaded from the app, I cannot see it in the bucket. What am I doing wrong?

推荐答案

你有没有打电话给 move_uploaded_file 在脚本执行期间从临时GCS文件名移动文件?

Did you call move_uploaded_file during the script execution to move the file from the temporary GCS filename?

在脚本执行结束时,所有临时文件(即$ _FILES ['userfile'] ['tmp_name'])都被垃圾收集并从存储桶中删除。

At the end of the script execution, all of the temporary files (i.e. $_FILES['userfile']['tmp_name']) are garbage collected and removed from the bucket.

这篇关于存储桶中不存在使用Google App Engine应用程序成功上传的图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆