Appengine Cloud Storage上传图像并存储在存储中

I have a problem. any help is welcome.

I am developing a solution that need to use google apis like cloud storage, Drive, etc.

In the clasic profile page I have to upload picture profile. then I use a angularjs to post data to my appengine/php/yii

formPHP:

`

<?php
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = [ 'gs_bucket_name' => 'seektrabajo' ];
$upload_url = CloudStorageTools::createUploadUrl('/perfiles/subirFotoPerfil', $options);
?>
<input type="file" name="file" 
       nv-file-select="uploader.uploadAll()" 
       uploader="uploader"   />

`

and when submit send data to google and google to yii ajax service:

`

public function actionSubirFotoPerfil(){
     $answer = array('answer'=>'Incompleted','serverFile'=>'sinfoto.png');
     if(!empty( $_FILES )){
         $filename = $_FILES['file']['name'];
         $gs_name =  $_FILES['file']['tmp_name'];
         move_uploaded_file($gs_name, 'gs://seektrabajo/'.$filename);
         $answer = array( 'answer' => 'File transfer completed','serverFile' => $filename);
     }
     echo json_encode( $answer );
     Yii::app()->end();
 }

`

the problem is that never save the file uploaded to my bucket on cloud storage. this not work for development/local mode and either appengine deployed. in appengine land, I get this error:

I just get permision to bucket:

gsutil acl ch -u user@gmail.com:FULL_CONTROL gs://seektrabajo

the user@gmail.com y get from my google console/ apis-autentications/ Email

![web browser console error][1]

http://i.stack.imgur.com/noKnh.png

Somebody have an idea? Thanks.

Why are you uploading the files to a static handler then uploading them to GCS? Use createUploadUrl() to template the <form> you serve. Provide a callback URL on your own app to the function and once the file is uploaded, a request will go to your app with the rest of the parameters of the form, the metadata of the file, etc...

With the pattern you are using, there is not only the headache of trying to figure out how to stream the data correctly, there's the simple fact that you're handling all that read/write on your instance, which is surely not a good idea if you intend to use this in production code where you pay for the used resources.

In short, there's no reason to use this pattern. In a traditional web app, you would post the file form to your own server on a route and do like you are in your example code (minus forwarding to GCS), but with App Engine you need to think a little different than the traditional ways of web development on a single VM you purchase and host a PHP runtime on.