Skip to content

Upload a file #26

@ChrisBtt

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.

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