Example #1
0
 def test_upload_stream(self):
     fn = gen_rand_nm()
     mmo = gen_rand_anon_mmap()
     h = hashing.IncrementalHasher()
     n = content.upload_stream(mmo, fn, parent=None, read_callbacks=[h.update])
     self.assertEqual(n['contentProperties']['md5'], h.get_result())
     trash.move_to_trash(n['id'])
Example #2
0
 def test_upload_stream(self):
     fn = gen_rand_nm()
     mmo = gen_rand_anon_mmap()
     h = hashing.IncrementalHasher()
     n = content.upload_stream(mmo,
                               fn,
                               parent=None,
                               read_callbacks=[h.update])
     self.assertEqual(n['contentProperties']['md5'], h.get_result())
     trash.move_to_trash(n['id'])
Example #3
0
def upload_stream(stream, file_name, parent_id, dedup=False,
                  pg_handler: progress.FileProgress=None) -> RetryRetVal:
    hasher = hashing.IncrementalHasher()
    try:
        r = content.upload_stream(stream, file_name, parent_id,
                                  read_callbacks=[hasher.update, pg_handler.update],
                                  deduplication=dedup)
        sync.insert_node(r)
        node = query.get_node(r['id'])
        return compare_hashes(node.md5, hasher.get_result(), 'stream')
    except RequestError as e:
        logger.error('Error uploading stream. Code: %s, msg: %s' % (e.status_code, e.msg))
        return UL_DL_FAILED
Example #4
0
def upload_stream(stream, file_name, parent_id, dedup=False,
                  pg_handler: progress.FileProgress=None) -> RetryRetVal:
    hasher = hashing.IncrementalHasher()
    try:
        r = content.upload_stream(stream, file_name, parent_id,
                                  read_callbacks=[hasher.update, pg_handler.update],
                                  deduplication=dedup)
        sync.insert_node(r)
        node = query.get_node(r['id'])
        return compare_hashes(node.md5, hasher.get_result(), 'stream')
    except RequestError as e:
        logger.error('Error uploading stream. Code: %s, msg: %s' % (e.status_code, e.msg))
        return UL_DL_FAILED