supabase / storage-py

Home Page:https://supabase-community.github.io/storage-py/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PUT requests for storage uploads

lrajca opened this issue · comments

Is your feature request related to a problem? Please describe.
Not sure if this is already supported somehow already that I've missed. Would be nice to be able to PUT objects to overwrite the contents, currently attempts using upload() returns a

{'statusCode': 400, 'error': 'Duplicate', 'message': 'The resource already exists'}

Describe the solution you'd like
Either we could add a parameter to the existing upload function to define the HTTP Method, or just add a new method.

ie

class HttpMethod(Enum):
    PUT = "PUT"
    POST = "POST"
    
  def upload(... method: HttpMethod = HttpMethod.POST):
       ....
       return self._request(
            method,
            f"/object/{_path}",
            files=files,
            headers=headers,
        )

Hey!

Thanks for flagging this - I don't think this exists at the moment. PRs are welcome!

commented

@lrajca sorry for the late response - passing upsert in the file_options parameter should overwrite contents

client.from_("bucket").upload("filename.txt", open("filename.txt", "rb"), {"x-upsert": "true"})