Esempio n. 1
0
 def init_multipart_upload(self):
     is_available, code = upload_lock_acquire(self.filename, INITIATE_UPLOAD_PART_NUM)
     if code == UPLOAD_ACQUIRE_FINISH_TIME_OUT:
         self.storage.cancel_upload(self.filename, self.mp)
     if is_available:
         mp = self.storage.init_multipart_upload(self.filename)
         if not mp:
             upload_lock_release(self.filename, INITIATE_UPLOAD_PART_NUM)
         else:
             # upload_lock_finish(self.filename, INITIATE_UPLOAD_PART_NUM)
             return mp
     return None
Esempio n. 2
0
 def process_file(self):
     is_available, code = upload_lock_acquire(self.filename, COMPLETE_UPLOAD_PART_NUM)
     if is_available:
         if self.storage.complete_upload(self.filename, self.mp):
             # upload_lock_finish(self.filename, COMPLETE_UPLOAD_PART_NUM)
             if self.file_md5sum and not self.check_whole_md5():
                 self.storage.cancel_upload(self.filename, self.mp)
                 self.storage.delete(self.filename)
                 upload_lock_release(self.filename)
                 return UPLOAD_ERR_FILE_MD5_ERR_ERR
             return UPLOAD_ERR_COMPLETE_SUCCESS
         else:
             upload_lock_release(self.filename, COMPLETE_UPLOAD_PART_NUM)
             return UPLOAD_ERR_COMPLETE_UPLOAD_ERROR
     return UPLOAD_ERR_CANNOT_LOCK_ERROR
Esempio n. 3
0
    def process_chunk(self, file):
        part_num = int(self.kwargs.get('resumableChunkNumber'))
        size = int(self.kwargs.get('resumableTotalSize'))
        md5 = self.kwargs.get('md5sum', "")

        is_available, code = upload_lock_acquire(self.filename, part_num)
        if is_available:
            if self.storage.upload_part(content=file, obj_path=self.filename, part_num=part_num, size=size, found_mp=self.mp, md5=md5):
                # upload_lock_finish(self.filename, part_num)
                return UPLOAD_ERR_PART_SUCCESS
            else:
                upload_lock_release(self.filename, part_num)
                return UPLOAD_ERR_PART_UPLOAD_ERROR
        else:
            return UPLOAD_ERR_CANNOT_LOCK_ERROR