コード例 #1
0
ファイル: monitor.py プロジェクト: vangheem/clouddrive
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
コード例 #2
0
ファイル: monitor.py プロジェクト: vangheem/clouddrive
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
コード例 #3
0
ファイル: monitor.py プロジェクト: vangheem/clouddrive
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
コード例 #4
0
ファイル: monitor.py プロジェクト: vangheem/clouddrive
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