Skip to content

Storage: Inefficient Resource Management #2

@codeCraft-Ritik

Description

@codeCraft-Ritik

The Issue:

The file upload logic in src/provider/supabaseProvider.jsx uses the original file name in the storage path: images/${user.id}/${file.name}.

The Bug:
If a user uploads multiple versions of a profile picture with different filenames, the project retains every version in storage.

Summary & Fix:
The storage bucket will eventually accumulate abandoned images, wasting resources. The system should standardize the filename (e.g., profile_image) so that every new upload automatically overwrites the previous one for that user.

Vulnerable Code Snippet:

// src/provider/supabaseProvider.jsx
const uploadFileWithProgress = async (file, onProgress) => {
  if (!file || !user?.id) return console.warn("Missing file or user");

  const bucket = "files";
  const path = `images/${user.id}/${file.name}`; // BUG: Does not overwrite old photos if names differ

  try {
    const { data: urlData, error: urlError } = await supabase.storage.from(bucket).createSignedUploadUrl(path);
    // ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions