Skip to content

Upload a file #26

Description

@ChrisBtt

Hey,

as far as I understand the documentation and the code of the class itself, no functionality for uploading a file is given.

I am able to connect to a Seafile server and create an empty file with this URL:
file_name = os.path.basename(file_path) file_url = os.path.join(server_url, 'lib', repo_id, 'file', file_name)

Is there a better alternative implemented than using the existing requests library and simply post the file content?
response = requests.post(file_url, files=files, headers=headers)
with

auth_response = requests.post(f"{server_url}api2/auth-token/", data={'username': username, 'password': password})
token = auth_response.json().get('token')
headers = {'Authorization': f'Token {token}'}
files = {'file': (file_name, open(file_path, 'rb'))}

I am happy about any recommendations to some more detailed documentation or a code example.
Later on, I can add the solution to the documentation for following users.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions