Upload file to specific location or move file after upload

Hi there,

Goal: Upload file to specific location using Python library API.

When I'm doing it, it always upload to root folder of the share and not to the location I specified:

api = BasicClient(API_KEY, API_PW)
f = open(path_to_upload, 'rb')
location = '/Escalation/auto_upload_files/'
abs_upload = location + file_to_upload
r = api.upload(abs_upload, f)

Since the above doesn't work and it is always uploaded to root folder, I decided to upload it to root and move it to my desired location using https://github.com/smartfile/client-python/ documentation:

r = api.move('{}'.format(file_to_upload), '/Escalation/auto_upload_files/{}'.format(file_to_upload))

while True:
        s = api.get('/task', r['uuid'])
        if s['result']['status'] == 'SUCCESS':
        elif s['result']['status'] == 'FAILTURE':
            LOGGER.info("TASK FAILURE: " + s['uuid'])
    except Exception as e:
        print e

Res from server:

{u'status': u'SUCCESS', u'result': {u'total': 1, u'errors': {u'/test.txt/': u'Parent directory is missing: /mnt/mfs00/data04/6f/34/6f346492a7396d619d26298f6bdf3242/root/Escalation/auto_upload_files/test.txt/test.txt'}, u'complete': 1}}, u'type': u'Move'}

For some reason, the API uses the file name as folder and this folder doesn't exist obviously.

Is this API creates a new folder every time it been used?


Thank you in advance.

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 1 mth agoLast active
  • 8Views
  • 1 Following