Uploadify uploading arbitrary file to s3 with correct Content-type

拜拜、爱过 提交于 2019-12-12 00:54:52

问题


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 callback 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.


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/5228142/uploadify-uploading-arbitrary-file-to-s3-with-correct-content-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!