I have the following code:
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);
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>
Below is the content of upload_handler.php:
<?php
var_dump($_FILES);
?>
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)
}
}
}
The permissions set for the bucket "myuserpics" are the default permissions.
When I look in the bucket, I do not see the uploaded image.
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?
Aucun commentaire:
Enregistrer un commentaire