开发者

Uploadify uploading arbitrary file to s3 with correct Content-type

开发者 https://www.devze.com 2023-02-15 16:05 出处:网络
I need to be able to upload any file type, for example, both pdf and jpeg. S3 requires the content-type be set at the time of upload, or the file will not be served correctly

I need to be able to upload any file type, for example, both pdf and jpeg. S3 requires the content-type be set at the time of upload, or the file will not be served correctly

Is it possible to dynamically assign the content-type in the onSelect c开发者_如何学编程allback or elsewhere?

The content-type is set in the postData parameter to uploadify (scriptData in older uploadify versions). Right now I have no way to set this until a file is selected. After the file is selected I could determine (mostly accurately) the content-type from the file extension. Now all files are served as application/octet-stream, which makes them pretty useless.


You can set the metadata including content-type of an existing S3 object by copying the object to itself and specifying the new data.


This can be accomplished using uploadifySettings() in a callback:

  • onUploadStart seems to work fine in 3.0.0. In 2.x, this was called onOpen and the documentation says that it did not work.

  • onSelect works with single files, but not with multiple files of different types because the selection events are called at the same time

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号