supabase-js
supabase-js copied to clipboard
`createUploadSignedUrl` with upsert does not work
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
There is an existing issue, https://github.com/supabase/storage/issues/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
- 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,
});
- 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.
Hello @saqibameen I cannot reproduce the issue.
Can you provide the code on how you are uploading the file using the signedUploadUrl?
@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.
@fenos
- You have a file called
1.pdf - you use
signedUploadUrlto get a signedUrl and thencreateSignedUploadUrlto upload - you made changes to
1.pdfand now need to overwrite the file - you use
signedUploadUrlagain with same file1.pdfand you get an error thatThe resource already exists signedUploadUrlupsert doesn't work
Our prod is impacted coz of this.
@thorwebdev has more context. FYI @kiwicopple
@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?
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!
@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-jsversion in yourlockfile please?
@thorwebdev the storage-js version is 2.6.0. - @supabase/[email protected]
@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?
This issue has been automatically marked as stale because it has not had any activity for 1 year. It will be closed in 6 months if no further activity occurs. If this issue is still relevant, please comment to keep it open.