def overwrite_file(filepath, folder_node, _id): stats.record_filestart(filepath) filename = filepath.split('/')[-1].replace('"', 'quote').replace("'", 'quote') _type = mimetypes.guess_type(filename)[0] or 'application/octet-stream' result = api.call('nodes/%s/content?suppress=deduplication' % _id, method='PUT', args={ 'files': [('content', (filename, open(filepath, 'rb'), _type))] }).json() stats.record_filedone() return result
def upload_file(filepath, folder_node): stats.record_filestart(filepath) filename = filepath.split('/')[-1].replace('"', 'quote').replace("'", 'quote') _type = mimetypes.guess_type(filename)[0] or 'application/octet-stream' result = api.call('nodes?suppress=deduplication', method='POST', body={ 'metadata': json.dumps({ 'name': filename, 'kind': 'FILE', 'parents': [folder_node['id']] }) }, body_type='data', args={ 'files': [('content', (filename, open(filepath, 'rb'), _type))] } ).json() stats.record_filedone() return result
def upload_file(filepath, folder_node): stats.record_filestart(filepath) filename = filepath.split('/')[-1].replace('"', 'quote').replace("'", 'quote') _type = mimetypes.guess_type(filename)[0] or 'application/octet-stream' result = api.call('nodes?suppress=deduplication', method='POST', body={ 'metadata': json.dumps({ 'name': filename, 'kind': 'FILE', 'parents': [folder_node['id']] }) }, body_type='data', args={ 'files': [('content', (filename, open(filepath, 'rb'), _type))] }).json() stats.record_filedone() return result