Closed redfellow closed 3 years ago
How are you uploading the file?
(it turns it into a blob because file constructor isn't supported on old IE)
server: {
process: component.processFile,
}
And the upload logic is our own. It's basically and endpoint that eats multiple formData
objects containing a File
each.
Snip:
var xhr = new XMLHttpRequest();
xhr.open("POST", parameters.serviceurl, true);
xhr.onload = function (error) {
...
};
xhr.upload.onprogress = function (e) {
...
};
xhr.onerror = function (error) {
...
}
xhr.send(formData);
The File
object limitation/requirement comes from the server side. We could perhaps work around this. It's still confusing as to why the rename plugin turns the File
object inside fileponds getFiles
to a Blob
.
Edit: I might of just now understood your comment, the renaming of a file creates a new File, but since this isn't supported on IE, the renamer uses just a Blob for compatability?
Because renaming a file requires creating a new file. https://pqina.nl/blog/rename-a-file-with-javascript/
How are you creating the formData
, the approach below should work.
const formData = new FormData();
formData.append(fieldName, file, file.name);
Thanks for setting me on correct path. I refactored the upload logic to use that style of formData.append vs. just key/value that we had.
Simply initing filePond with
fileRenameFunction: function(file) { return file.name }
changes how the file appears in formData.Should look like this (no function set):
The renaming does work UI-wise, the preview box has the correct filename, it's just when starting the actual upload, things break.
Output of
pond.getFiles()
when function is in use:And when not in use:
So from quick look, it looks like when renamer is in use, the file object in getfiles is actually a blob and not a File (instance of a blob)?
Any way to fix this?