Urgent.News

What's breaking now, across thousands of outlets.

Tech

WebP and AVIF Image Thumbnail Recovery — Safe File Naming in Object Storage

Short answer: use an immutable key per upload and per derivative size, keep the original under a generation prefix, and copy it to an archive key before generating thumbnails. Object storage is a good fit for ordinary e-commerce image delivery; it is a poor fit when recovery from an accidental overwrite or strict writer concurrency is the primary requirement. That decision is less about WebP…

In the realm of e-commerce, handling image files in various formats like WebP and AVIF can be tricky when it comes to ensuring data safety and proper naming conventions in object storage systems. To maintain a robust system, it is crucial to follow certain guidelines and best practices.

Firstly, use an immutable key for every upload and derivative size. This means that each upload and derivative should have a unique identifier, ensuring that no data is overwritten or altered in any way. Additionally, keep the original image under a generation prefix, which means that the original image file should be stored with a specific naming convention that helps in tracking its revisions.

When generating thumbnails, it is essential to copy the original image to an archive key before proceeding with the thumbnail creation process. This step provides a safety net in case of accidental overwrites or strict writer concurrency issues. By doing so, you can recover from any errors that may occur during the thumbnail generation process.

While both WebP and AVIF image formats have their advantages, the choice between the two ultimately depends on the specific requirements of your project and the level of control you have over the write boundary. In most cases, the database should own the current image manifest, while the object storage system should store the immutable bytes. This separation of responsibilities ensures that the system remains stable and reliable.

To illustrate this concept, let's consider an example of how an e-commerce product image might be structured in the object storage system. For instance, a product image with the SKU number 1842 might be stored in the following location: products/sku-1842/01c8f7/original.jpg. The derivatives of this image, such as WebP and AVIF versions, would be stored in separate directories, such as .../webp/640.webp and .../avif/1280.avif.

The key to ensuring data safety lies in the naming convention of the object storage system. Each generation of an image file should have a unique identifier, and size and format should be part of the key rather than mutable metadata. A derivative should only be published once its bytes are complete and validated, and the manifest should point to that key. This approach allows for easy recovery in case of any errors or accidental overwrites.

When it comes to handling overwrites and concurrency issues, it is essential to design the system in a way that allows for retries without changing the meaning of an existing key. This means that client-supplied idempotency data should be stored in the job record, even if the storage API does not expose a conditional write feature.

In summary, the naming convention for object storage systems handling image files in e-commerce should include a unique generation id, size and format as part of the key, and a copy of the original image stored under an archive prefix before generating thumbnails. By following these guidelines, you can ensure that your system is robust, reliable, and able to handle any errors or overwrites that may occur.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

ElevenLabs + React: Building a Voice-Enabled UI

Why Voice‑Enabled UI Matters Every day we interact with voice assistants, chatbots, and smart devices. Even if you’re a web developer who’s never written a line of code for speech, adding a voice…

  • Voice-enabled interfaces enhance accessibility and engagement.
  • ElevenLabs provides API for high-quality text-to-speech.
  • React integration involves backend handling of API authentication.

Stop paying for the CPU your pods leave idle

Last year somebody set cpu: 1 on a Deployment. It felt safe. Today the process uses about a third of that core. The scheduler doesn't care.

  • Kubernetes Deployment configured with 1 core CPU request
  • Scheduler reserves 2/3 of core, leaving 1/3 idle 24/7
  • Attune automates CPU request adjustment in-place

More from Wednesday 4 November →