Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mcs/api/bucket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def list_files(self, bucket_name, prefix='', limit='10', offset="0"):
return False


def upload_file(self, bucket_name, object_name, file_path):
def upload_file(self, bucket_name, object_name, file_path, replace=False):
prefix, file_name = object_to_filename(object_name)
bucket_id = self._get_bucket_id(bucket_name)
if os.stat(file_path).st_size == 0:
Expand All @@ -160,6 +160,10 @@ def upload_file(self, bucket_name, object_name, file_path):
if result is None:
logging.error("\033[31mCan't find this bucket\033[0m")
return
# Replace file if already existed
if result[['data']['file_is_exist']] and replace:
self.delete_file(bucket_name, object_name)
result = self._check_file(bucket_id, file_hash, file_name, prefix)
if not (result['data']['file_is_exist']):
if not (result['data']['ipfs_is_exist']):
with open(file_path, 'rb') as file:
Expand Down