Nice article! I’m assuming the output bucket stores the image under the same key as was provided to the input bucket — yeah? So for example if I uploaded a profile picture, I can save the ouput_bucket/key combo to my profile picture field in the database. Is that how you’re approaching this here from the frontend’s perspective? Obviously the frontend is clueless as to when the transformation is finished, which is why I’m asking.
Thanks! Yep, spot on. The image uses the same key in both buckets. As for the front end, there’s a couple of options you could do. Update your db record with the compressed bucket / key path immediately, but also keep a cached version of the uploaded file in the browser session after the user uploads. This way you can use the original image straight away, and wait for the compression to complete a second or two later. Alternatively, you could have a fallback strategy when loading the image - e.g try loading the compressed bucket key path and if that fails load in the source bucket key path.
Depending on the size of the images you are working with, the actual compression/conversion time is pretty damn quick, and you could bump up your lambda memory allocation to try and process things a little faster. So it’s possible that you could just use the compressed bucket key path directly without skipping a beat.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice article! I’m assuming the output bucket stores the image under the same key as was provided to the input bucket — yeah? So for example if I uploaded a profile picture, I can save the ouput_bucket/key combo to my profile picture field in the database. Is that how you’re approaching this here from the frontend’s perspective? Obviously the frontend is clueless as to when the transformation is finished, which is why I’m asking.
Thanks! Yep, spot on. The image uses the same key in both buckets. As for the front end, there’s a couple of options you could do. Update your db record with the compressed bucket / key path immediately, but also keep a cached version of the uploaded file in the browser session after the user uploads. This way you can use the original image straight away, and wait for the compression to complete a second or two later. Alternatively, you could have a fallback strategy when loading the image - e.g try loading the compressed bucket key path and if that fails load in the source bucket key path.
Depending on the size of the images you are working with, the actual compression/conversion time is pretty damn quick, and you could bump up your lambda memory allocation to try and process things a little faster. So it’s possible that you could just use the compressed bucket key path directly without skipping a beat.