def run(self): files = self._get_files() if files: print_color('Removing remote files...', 'magenta') for file_key in files: ret, error = qiniu.rs.Client().delete(self.bucket_name, file_key) if error is not None: print_color('Remote file %s removed failed' % file_key, 'red') else: print('Remote file %s removed successful' % file_key)
def run(self): files = self._get_files() if files: print_color('Uploading local files...', 'magenta') for file_path in files: file_key = self._get_file_key(file_path) uptoken = qiniu.rs.PutPolicy( '%s:%s' % (self.bucket_name, file_key) ).token() ret, error = qiniu.io.put_file( uptoken, file_key, file_path ) if error is not None: print_color('File %s uploaded failed' % file_path, 'red') else: print('File %s uploaded successful' % file_path)