Python FileStorageService Documentation

Methods

get_file

get_file(file_name, expiration_time=timedelta(minutes=60))

Returns a signed url to the file with the given file name if found

Arguments:

  • file_name: name of the file
  • :type file_name: str
  • expiration_time: the lifetime of the url, defaults to timedelta(minutes=60)
  • :type expiration_time: timedelta, optional

Returns:

Signed url of the file (:rtype str or None if file is not found)

create_file

create_file(file_name, file, content_type=None)

Creates a file in the default bucket with given file name

Arguments:

  • file_name: name of the file
  • :type file_name: str
  • file: file to upload
  • :type file: file
  • content_type: MIME type of the file, defaults to None
  • :type content_type: str, optional

Raises:

  • Exception: file name already exists

update_file

update_file(file_name, file, content_type=None)

Replaces the file that has given file name in default bucket

Arguments:

  • file_name: name of the file
  • :type file_name: str
  • file: file to replace with
  • :type file: file
  • content_type: MIME type of the file, defaults to None
  • :type content_type: str, optional

Raises:

  • Exception: file name does not already exist

delete_file

delete_file(file_name)

Deletes the file with the given file name

Arguments:

  • file_name: name of the file
  • :type file_name: str

Raises:

  • Exception: file not found