inertia
inertia copied to clipboard
fix: Blob could have a name as well
When creating a Blob, it's very much possible to give it a name
Use case: I'm transforming an image File and thus need to convert it to a Blob and assign it the original file properties
Eg:
const blob = new Blob(transformedFiled, {type : 'image/jpeg'});
blob.name = originalFile.name;
But currently the code treats Blob and Files differently and it's not possible to send a file name with a Blob
Blob doesn't have a name attribute, it's an arbitrary attribute, just as you could do blob.asdf = 'something', see https://developer.mozilla.org/en-US/docs/Web/API/Blob for more info
You can just transform it to a file and set the name, right? So following your example above, that would be:
const blob = new Blob(transformedFiled, {type : 'image/jpeg'});
const file = new File([blob], originalFile.name, { type: 'image/jpeg' });
I know it doesn't, but it can't hurt to pass it if set manually, if it wasn't then nothing changes, lots of plugins do it like this (like filepond) because the file constructor is not that well supported. See https://stackoverflow.com/questions/8390855/how-to-instantiate-a-file-object-in-javascript
Hey! Thanks so much for your interest in Inertia.js and for submitting this contribution.
In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.
Of course there's a chance that this PR is still relevant, and if that's the case feel free to re-submit it. If it's a new feature and not a bug fix maybe respond here first to make sure that it's something we want to include in the library.
Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️