简体   繁体   中英

Specify actual content-type of a uploaded file

I'm working on a blob upload service and I have this code that persist uploaded meta-data in the Datastore and the actual bytes into the Blobstore.

I am having issues with the Mime-Type provided by the REST client (I am using the Rest Console Chrome plugin)

This is the mime-type that is passed from the client to the server:

Mime type:  multipart/form-data; boundary=----WebKitFormBoundarytxCVEFIRjPB7YIq7

However the server needs to get the "actual mime-type", that is, for example image/jpeg, image/jpeg, text/plain, etc.

Using the App Engine API I need to explicitly provide the mime-type like this:

AppEngineFile file = fileService.createNewBlobFile(entity.getMimeType());

How do I specify this? Do I need to put another header? The files that will be uploaded will vary and that the file can be up to 50MB in size (If I remember that correctly).

"Multipart" means that the data sent can have multiple parts, each with it's own mime type. Read about handling multipart form uploads on GAE.

You can use FileItemStream.getContentType() to get mime type of each part.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM