Step by step I’m pushing my project to production, I’m using firebase for phone authentication and decide to store there some images as well. I have created an adapter for firebase storage and successfully generate thumbnails.
Is there any proper way to get thumbnails through the Android and iOS SDK because the ParseFile will point to the original file.
Is direct access the only way?
Parse.Cloud.afterSaveFile(async (request) => {
const file = request.file;
const fileData = await file.getData();
const fileBuffer = Buffer.from(fileData, 'base64');
const mimeInfo = await fileType.fromBuffer(fileBuffer);
console.log(mimeInfo);
if(!mimeInfo.mime.startsWith("image")){
//If file is image then we create imageThumbnail
//percentage value determines the quality of imageThumbnail
//Lower value means lover quality and lower file size
//I personally use 5 because ıt ussually generates thumbnail smaller than 1KB
let options = { percentage: 5, responseType: 'base64' };
const thumbnail = await imageThumbnail(fileBuffer, options);
var thumbfile = new Parse.File("thumbMedia.jpg", { base64: thumbnail });
const t2 = await thumbfile.save();
//Now t2 is your thumbnail file. Do whatever you want with it.
}
});
You are taking the Parse approach by creating new files on Parse. I generate thumbnails and upload them directly to firebase through the storage adapter, so on Parse side only 1 file is saved, but in the storage there are the thumbnails next to the original uploaded file.
So basically I’m trying to have only one ParseFile let’s say ‘Avatar’ in my ParseObject and have the ability to decide which version of the avatar to load on the client.
As you mention the ideal should be on Android/iOS to load initially very blurry (small) version of the image and then to load one of the big thumbnails.
In Google Cloud I have 3 files - original + 2 thumbnails. On the Parse server I have only the original file as ParseFile. My questions is if is there any way to specify though the Parse SDK the ParseFile url manually.
Can I get the ParseFile url without downloading the original file and build the thumbnail url, so I can use what you propose in your previous answer?
@uzaysan does this clear the picture a little bit? I know that is a strange approach…