[英]How to set Content-Type automatically when i download the data that i uploaded.
[英]How to discard uploaded file if content-type is not allowed?
我正在尝试阻止不需要的内容类型的上传文件。 我正在使用文档中的代码 :
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
upload_files = self.get_uploads('file') # 'file' is file upload field in the form
blob_info = upload_files[0]
self.redirect('/serve/%s' % blob_info.key())
我发现在最后一行重定向之前,blob已经在blobstore中,所以剩下要做的就是检查它的内容类型,如果不需要则执行删除。
有什么其他方法可以在文件到达blobstore之前将其丢弃吗?
在它到达Blobstore之前执行它的唯一方法是在客户端,例如通过使用javascript检查文件的扩展名。
一旦它打到你的UploadHandler它已经在BlobStore中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.