Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python get_uploads from Blobstore Upload返回空列表,尽管文件显示在bucket中_Python_Google App Engine_File Upload_Google Cloud Storage_Blobstore - Fatal编程技术网

Python get_uploads from Blobstore Upload返回空列表,尽管文件显示在bucket中

Python get_uploads from Blobstore Upload返回空列表,尽管文件显示在bucket中,python,google-app-engine,file-upload,google-cloud-storage,blobstore,Python,Google App Engine,File Upload,Google Cloud Storage,Blobstore,我最近从开发服务器部署了我的python GAE应用程序,我的图像上传功能停止正常工作 经过一点测试后,blobstore的get_uploads函数似乎返回了一个空列表,因此我从上传处理程序中得到了一个索引外错误(也尝试了get_file_infos函数,得到了相同的结果) 但是,当我检查GCS浏览器时,文件已正确上载,因此我的问题似乎是找不到从post to Upload处理程序中提取图像链接的方法 有人知道为什么会这样吗?如果有办法的话 (表单使用带有多部分/表单数据的post方法,希望这

我最近从开发服务器部署了我的python GAE应用程序,我的图像上传功能停止正常工作

经过一点测试后,blobstore的get_uploads函数似乎返回了一个空列表,因此我从上传处理程序中得到了一个索引外错误(也尝试了get_file_infos函数,得到了相同的结果)

但是,当我检查GCS浏览器时,文件已正确上载,因此我的问题似乎是找不到从post to Upload处理程序中提取图像链接的方法

有人知道为什么会这样吗?如果有办法的话

(表单使用带有多部分/表单数据的post方法,希望这不是问题)

  • 下面是我调用的用于向上载处理程序发布的函数:

    upload_url = blobstore.create_upload_url('/upload', gs_bucket_name='BUCKET')
    result = urlfetch.fetch(url= upload_url,
                            payload=self.request.body,
                            method=urlfetch.POST,
                            headers=self.request.headers)
    
    class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
        def post(self):
            upload_files = self.get_uploads('file')
            blob_info = upload_files[0]
            self.response.write(str(blob_info.key()))
    
  • 下面是上载处理程序的代码:

    upload_url = blobstore.create_upload_url('/upload', gs_bucket_name='BUCKET')
    result = urlfetch.fetch(url= upload_url,
                            payload=self.request.body,
                            method=urlfetch.POST,
                            headers=self.request.headers)
    
    class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
        def post(self):
            upload_files = self.get_uploads('file')
            blob_info = upload_files[0]
            self.response.write(str(blob_info.key()))
    

    • 你想做什么

      看起来你想把收到的尸体发到地面军事系统。为什么不使用Google云存储客户端库编写它呢

      with gcs.open(gcs_filename, 'w', content_type, options={b'x-goog-acl': b'public-read'}) as f:
          f.write(blob) 
      

      好的,我试试看。。不过我还是不太熟悉它的工作原理,你能给我提供一些参考资料吗?