Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createUploadSignedUrl with upsert does not work #1246

Open
2 tasks done
saqibameen opened this issue Jul 17, 2024 · 7 comments
Open
2 tasks done

createUploadSignedUrl with upsert does not work #1246

saqibameen opened this issue Jul 17, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@saqibameen
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

There is an existing issue, supabase/storage#502 but it is closed without resolution.

Describe the bug

I am unable to create a signedUploadUrl if the file already exists. I am using upsert: true but it still gives resource already exists error.

To Reproduce

  1. I am using following snippet to create signedUploadUrl and upload a file.
const {data: signedUploadUrlData, error: signedUploadUrlError} = await supabase.storage
	.from('files')
	.createSignedUploadUrl(`${path}`, {
		upsert: true,
	});
  1. Once file is uploaded, try creating another signedUploadUrl using code snippet in 1. It gives error:
{
  "name": "StorageApiError",
  "message": "The resource already exists",
  "status": 400
}

Expected behavior

It should create a new signedUploadUrl.

System information

  • OS: macOS
  • Version of supabase-js: 2.44.4
  • Version of Node.js: NA (using cloudflare worker)

Additional context

Add any other context about the problem here.

@saqibameen saqibameen added the bug Something isn't working label Jul 17, 2024
@fenos
Copy link
Contributor

fenos commented Jul 18, 2024

Hello @saqibameen
I cannot reproduce the issue.

Can you provide the code on how you are uploading the file using the signedUploadUrl?

@saqibameen
Copy link
Author

@fenos so the error occurs at createSignedUploadUrl not while using the the signedUploadUrl to upload a file. The snippet shared above is how I am trying to create a signedUploadUrl.

@ahmadawais
Copy link

ahmadawais commented Jul 19, 2024

@fenos

  1. You have a file called 1.pdf
  2. you use signedUploadUrl to get a signedUrl and then createSignedUploadUrl to upload
  3. you made changes to 1.pdf and now need to overwrite the file
  4. you use signedUploadUrl again with same file 1.pdf and you get an error that The resource already exists
  5. signedUploadUrl upsert doesn't work

Our prod is impacted coz of this.

@thorwebdev has more context.
FYI @kiwicopple

@thorwebdev
Copy link
Member

@ahmadawais I'm not able to reproduce this either. I tested with this: https://github.com/calcom/platform-starter-kit/blob/main/src/app/api/supabase/storage/route.ts#L18-L20 and it works fine. Can you double check your storage-js version in your lock file please?

@thorwebdev
Copy link
Member

You can verify that the upsert param is being sent correctly by checking the storage logs (https://supabase.com/dashboard/project/_/logs/storage-logs) for the /object/upload/sign request and validate that the "x_upsert": "true" req header is set correctly. If that isn't the case, something is off with your supabase-js/storage-js versions!

@saqibameen
Copy link
Author

saqibameen commented Jul 22, 2024

@ahmadawais I'm not able to reproduce this either. I tested with this: https://github.com/calcom/platform-starter-kit/blob/main/src/app/api/supabase/storage/route.ts#L18-L20 and it works fine. Can you double check your storage-js version in your lock file please?

@thorwebdev the storage-js version is 2.6.0. - @supabase/[email protected]

@saqibameen
Copy link
Author

@thorwebdev, @fenos thank you for checking. It turned out it was local only issue. It worked fine on production. I am now able to successfully generate uploadSignedUrl with upsert option.

Locally, I have updated the supabase package to latest and also tried updating the db container. I believe these logs: https://supabase.com/dashboard/project/_/logs/storage-logs are not locally available. Not sure why, any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants