Open walpolsh opened 2 years ago
Currently not supported.
Hello @fengyuanchen,
I have tested this lib for a while on Nuxt 2 and it's working pretty well. But, there is some problem when using it on Nuxt 3 and I couldn't get it working. I have a very similar code to the one you provided inside docs directory on github.
The result is success, no error log inside console log and the vm.output
data is updated to the new value (I have verified it through Vue DevTools) but there isn't anything changed to the browser/ui.
options: {
...
success: function (result) {
vm.output = result;
},
...
},
Not sure if you have meet this problem before. I couldn't figure out what is going on now.
@VisionaryAppDev Sorry, I haven't used Nuxt.
Hello @fengyuanchen,
I have tested this lib for a while on Nuxt 2 and it's working pretty well. But, there is some problem when using it on Nuxt 3 and I couldn't get it working. I have a very similar code to the one you provided inside docs directory on github.
The result is success, no error log inside console log and the
vm.output
data is updated to the new value (I have verified it through Vue DevTools) but there isn't anything changed to the browser/ui.options: { ... success: function (result) { vm.output = result; }, ... },
Not sure if you have meet this problem before. I couldn't figure out what is going on now.
can you provided me the code
A Temporary solution until this enhancement is added to the lib -
const removeExtension = (fileName: string) =>
fileName.substring(0, fileName.lastIndexOf('.')) || fileName;
export async function compress(file, quality, maxHeight, maxWidth) {
return await new Promise((resolve, reject) => {
new Compressor(file, {
quality,
maxHeight,
maxWidth,
success: (compressedFile) => {
if (compressedFile instanceof File) return resolve(compressedFile);
else {
const compressedFileFromBlob = new File([compressedFile], removeExtension(file.name), {
type: compressedFile.type,
});
return resolve(compressedFileFromBlob);
}
},
error: reject,
});
});
}
I'm just curious how to specify if a file or a blob is returned upon success?
This is how I'm using it:
In both cases I get a Blob back but would rather it remain file without doing another conversion
Thanks!