How to upload a file to a library using the seafile python api


#1

Hi there,

I am trying to upload a file to an existing seafile library using the python api (api.py):

seafile_api.post_file(repo_id,schedule_file,dirpath,schedule_name,owner)

however, I get

Traceback (most recent call last):
File “./seafile_ferien_setup.py”, line 106, in
seafile_api.post_file(repo_id,schedule_file,dirpath,schedule_name,owner)
File “/srv/seafile/seafile-server-latest/seafile/lib64/python2.7/site-packages/seaserv/api.py”, line 230, in post_file
filename, username)
File “/srv/seafile/seafile-server-latest/seafile/lib64/python2.7/site-packages/pysearpc/client.py”, line 112, in newfunc
return fret(ret_str)
File “/srv/seafile/seafile-server-latest/seafile/lib64/python2.7/site-packages/pysearpc/client.py”, line 11, in _fret_int
raise SearpcError(dicts[‘err_msg’])
pysearpc.common.SearpcError: Invalid input file

What works is to put an empty file (of the same name) into the library

seafile_api.post_empty_file(repo_id,dirpath,schedule_name,owner)

any hints here? unfortunately there is almost no documentation on the python api (I am only aware of this: https://github.com/haiwen/seafile-server/blob/master/python/seaserv/api.py )

any hints welcome.

best,
Hp


#2

ah, schedule_file (the local file) needs to be an absolute path.