在Google App Engine(Java)中限制Blobstore上传的文件类型 [英] Restricting file type on blobstore upload in Google App Engine (Java)

查看:70
本文介绍了在Google App Engine(Java)中限制Blobstore上传的文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用BlobstoreService将文件上传到AppEngine中的blobstore.如何限制文件的内容类型或文件类型?例如,我只想允许上传图像/jpeg文件.

I'm using BlobstoreService for uploading a file to blobstore in AppEngine. How to restrict the content-type or file type of the file? For example, I only want to allow upload for image/jpeg files.

推荐答案

无法禁止用户上传被禁止的文件类型a-priori,因为在他们做出POST,没有干净的方法可以终止POST请求.您可以在文件上传后检测到文件类型,但是如果禁止,则可以从Blob存储区中删除该文件.

There's no way to prohibit the user from uploading a prohibited filetype a-priori, because you can't tell what they're going to upload until they make the POST, and there's no clean way to terminate a POST request partway through. You can detect the filetype after they've uploaded the file, and delete the file from the blobstore if it's prohibited, however.

这篇关于在Google App Engine(Java)中限制Blobstore上传的文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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