thomasborgen / storage-bucket

For easy GCP Storage Bucket interaction
MIT License
6 stars 0 forks source link

Misleading API function names download_file and upload_file #57

Open thomasborgen opened 2 years ago

thomasborgen commented 2 years ago

Is your feature request related to a problem? Please describe.

download_file and upload_file function names are misleading.

The problem with download_file is that while it does consume a storage bucket blob, it does not write to a file, it just returns bytes. The problem with upload_file is that from the name one would expect the input to the function to be a filename, but it is actually bytes.

Describe the solution you'd like

Clearer api.

upload - input data: str | bytes upload_from_file - input filename: str

download - returns str | bytes download_to_file - return filename: str or absolute path to the file.

or have string and bytes spesific functions as well. but that might be a bit overkill.

thomasborgen commented 2 years ago

Maybe its not that straight forward. We decided not to call the blobs in storage bucket for blobs, but for files. Which kind of led to the names upload_file and download file.

Not a 100% sure how to move forward. My issue when i looked into changing it was this:

def download(storage_bucket_name, filename): ...

def download_to_file(storage_bucket_name, filename, local_filename): ...

The argument naming gets a bit weird 😓

So then maybe we should change the argument names aswell. But if we do that we should create a consistent naming standard and we should probably just follow what google does... Calling a blob a blob is probably just the easiest way forward where a blob is data in a storage bucket and a file is data stored in a conventional way.