programmatically passing FineUploader the location of the file to upload

时光毁灭记忆、已成空白 提交于 2019-12-13 07:37:38

问题


We have prototyped a client-side program that lets users select a local folder, creates a zip, then lets the local browser know about the zip file location via a local web socket. The intention is to then tell fineUploader about this new zip file location, so that it can immediately start the upload process.

But I'm not clear how to make this last part of the handoff. I just saw this post which sounds concerning.

Is there any way? If not, how might we make an acceptable user experience given that the user has selected a dir, it has been zipped for them, and we want the fineUploader component to process the upload?

Thanks!

Stu


回答1:


Code running in the browser is not able to access your filesystem directly. If you want to upload files, your users will have to manually select these files via drag-and-drop or an <input type="file"> chooser dialog.

However, if the zip file is accessible via HTTP or WS, this is possible. Assuming HTTP, you can make an ajax GET request for the zip file, read it into a Blob, and then send this Blob to Fine Uploader via the addFiles API method. If you're reading the file over WS, you'll need to take the returned data and convert it to a Blob using FileReader.

Note that this is not possible in browsers older than IE10.



来源:https://stackoverflow.com/questions/40362703/programmatically-passing-fineuploader-the-location-of-the-file-to-upload

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