问题
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