-
Notifications
You must be signed in to change notification settings - Fork 27
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
CreateSignedUrl fails when object content-type is different from "application/json" #24
Comments
I think I found the problem. // storage.go
func (c *Client) UploadOrUpdateFile(
bucketId string,
relativePath string,
data io.Reader,
update bool,
options ...FileOptions,
) (FileUploadResponse, error) {
path := removeEmptyFolderName(bucketId + "/" + relativePath)
uploadURL := c.clientTransport.baseUrl.String() + "/object/" + path
// Check on file options
if len(options) > 0 {
if options[0].CacheControl != nil {
c.clientTransport.header.Set("cache-control", *options[0].CacheControl)
}
if options[0].ContentType != nil {
c.clientTransport.header.Set("content-type", *options[0].ContentType) // <-- content-type is set to whatever you put
}
if options[0].Upsert != nil {
c.clientTransport.header.Set("x-upsert", strconv.FormatBool(*options[0].Upsert))
}
} This header doesn't get reset back to "application/json", so when you fire the next request (in my case to generate a signed URL to the object) it gets sent with the header you just set.
This happens when you set the content-type
If you add |
Hello @tranhoangvuit , this is an important fix, and not wanting to be a bother by asking, do we have plans for a new release?" |
Bug report
Describe the bug
CreateSignedUrl fails with
body must be object
when target object content-type is different from "application/json"To Reproduce
If you do not set
ContentType
, or set it to the default "application/json" it works.Expected behavior
Method should return the signed url regardless of content type
System information
Additional context
After some digging, the error seems to be coming from the execution of the request at
storage.go@CreateSignedUrl
However, I'm really new to Golang and don't really know what could be causing this. Maybe there's an option to parse non-JSON bodies differently?
Also, this is not on Supabase's side, as the NodeJS client seems to do this just fine
The text was updated successfully, but these errors were encountered: