如何将多个文件上传到BlobStore? [英] How to upload multiple files to BlobStore?

查看:101
本文介绍了如何将多个文件上传到BlobStore?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



表单:



<$ p

我试图将多个文件上载到BlobStore。 $ p> < form action ={{upload_url}}method =POSTenctype =multipart / form-data>
< label> Key Name< / label>< input type =textname =key_namesize =50>< br />
< label> name< / label>< input type =textname =namesize =50>< br />
< label>图片< / label>< input type =filename =imagesize =50>< br />
< label> thumb< / label>< input type =filename =thumbsize =50>< br />
< input type =submitname =submitvalue =Submit>
< / form>

然后,我尝试为上传的每个文件获取BlobInfo对象:

  def post(self):
image_upload_files = self.get_uploads('image')
thumb_upload_files = self.get_uploads( 'thumb')
image_blob_info = image_upload_files [0]
thumb_blob_info = thumb_upload_files [0]



我看到一些奇怪的行为。这两个文件都进入BlobStore,但我不知道如何获得密钥,以便我可以将其存储在另一个实体上。上面的代码设法获取image_blob_info的密钥,但不是thumb_blob_info。我不明白如何使用get_uploads。我想通过表单传递多个文件,然后通过名称获取它们,这样我就可以将它们存储在另一个实体的适当的BlobReferenceProperties中。

解决方案

每个文件都需要自己独特的上传网址,所以当我将所有三个文件发布到同一个网址时,我的猜测就是发生了一些古怪的事情。



支持多文件上传在Nick Johnson的博客文章中描述:

http://blog.notdot.net/2010/04/Implementing-a-dropbox-service-带有Blobstore-API-part-3-Multiple-upload-support


I'm trying to upload multiple files in a form to the BlobStore.

Form:

<form action="{{upload_url}}" method="POST" enctype="multipart/form-data">
  <label>Key Name</label><input type="text" name="key_name" size="50"><br/>
  <label>name</label><input type="text" name="name" size="50"><br/>
  <label>image</label><input type="file" name="image" size="50"><br/> 
  <label>thumb</label><input type="file" name="thumb" size="50"><br/> 
  <input type="submit" name="submit" value="Submit">
</form>

I'm then trying to fetch the BlobInfo objects for each of those files uploaded:

def post(self):
    image_upload_files = self.get_uploads('image') 
    thumb_upload_files = self.get_uploads('thumb') 
    image_blob_info = image_upload_files[0]
    thumb_blob_info = thumb_upload_files[0]

I'm seeing some weird behavior. Both files are making it into the BlobStore, but I cannot figure out how to get the Keys so that I can store those on another Entity. The code above manages to get the key for image_blob_info, but not thumb_blob_info. I don't understand how to use get_uploads. I want to pass multiple files through the form and then fetch them by name so I can store them in the appropriate BlobReferenceProperties on another Entity.

解决方案

Each file needs its own unique upload url, so my guess is something wacky is happening when all three files are posted to the same url.

The best solution for supporting multiple file uploads is described in Nick Johnson's blog post:

http://blog.notdot.net/2010/04/Implementing-a-dropbox-service-with-the-Blobstore-API-part-3-Multiple-upload-support

这篇关于如何将多个文件上传到BlobStore?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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