Me again… I think I found a workaround solution, dependent on the use case of the files you are saving to s3.
Originally, I was uploading images ~100 KB and was experiencing upload speeds between 10-30 seconds. I tried a few iterations of passing a base64 and/or buffer to my realm function without any positive results and given the simplicity of the function I explored the actual images themselves.
Now unfortunately my solution is specific to the package I am using, react-native-image-picker, so apologies that I can not give a better answer. In my case, the quality of the image was too ‘good’ or the size was too large.
Updating the function discussed earlier, I changed my maxWidth and maxHeight to 50 (from 256). The upload time is well under 2 seconds.
const onPressUploadImage = async () => {
launchImageLibrary({
mediaType: 'photo',
maxWidth: 50,
maxHeight: 50,
selectionLimit: 1,
includeBase64: true
}, (response) => {
const imageToUpload = response.assets[0].base64
setImage(imageToUpload)
})
}
Alternatively, and where I ultimately settled is reducing the quality of the image. Once again, this is specific to the frontend package I am working with but by setting the quality of the image to 0.5 vs. 1 (default?) I was able to set a higher max height and width but keep the upload time under 2 seconds.
const onPressUploadImage = async () => {
launchImageLibrary({
mediaType: 'photo',
maxWidth: 300,
maxHeight: 200,
quality: 0.5,
selectionLimit: 1,
includeBase64: true
}, (response) => {
const imageToUpload = response.assets[0].base64
setImage(imageToUpload)
})
}
With these small tweaks, I am now uploading images closer to 10 KB.
I know this comment is specific to frontend, but I would shocked if this is the right solution. Fortunately I am working with simple, smaller images but there does seem to be a larger issue at play here. I am probably overstepping my knowledge, but is 100 KB really too large of a file size?