在Google App Engine(Java)中限制blobstore上载的文件类型(Restricting file type on blobstore upload in Google App

编程入门 行业动态 更新时间:2024-10-22 23:31:32
在Google App Engine(Java)中限制blobstore上载的文件类型(Restricting file type on blobstore upload in Google App Engine (Java))

我正在使用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请求。 您可以在上传文件后检测文件类型,但如果禁止,则从blobstore中删除该文件。

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.

更多推荐

本文发布于:2023-07-06 07:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047347.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件类型   Java   Engine   App   Google

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!