def slice_upload(self):
        '''分片上传'''
        self.is_slice_upload = True
        fid = self.row[FID_COL]
        slice_start = self.row[CURRSIZE_COL]
        slice_end = self.row[CURRSIZE_COL]
        file_size = os.path.getsize(self.row[SOURCEPATH_COL])
        if file_size < slice_start:
            self.emit('disk-error', fid)
            return
        elif file_size == slice_start and slice_start == self.row[SIZE_COL]:
            self.emit('uploaded', fid)
            return
        fh = open(self.row[SOURCEPATH_COL], 'rb')
        fh.seek(slice_start)
        while self.row[STATE_COL] == State.UPLOADING:
            if slice_end >= file_size:
                self.emit('merge-files', self.row[FID_COL])
                break
            slice_start = slice_end
            slice_end = min(slice_start + self.row[THRESHOLD_COL], file_size)
            data = fh.read(slice_end - slice_start)
            slice_end = slice_start + len(data)
            info = pcs.slice_upload(self.cookie, data)
            if info and 'md5' in info:
                self.emit('slice-sent', fid, slice_end, info['md5'])
            else:
                self.emit('network-error', fid)
                break
        if not fh.closed:
            fh.close()
        return
分片上传