framedsc / HallOfFramed

Hall-of-framed website which contains various galleries with screenshots made by the members of the community
Creative Commons Zero v1.0 Universal
6 stars 4 forks source link

Figure out how to upload shots from a Python script to the chosen service #32

Closed originalnicodr closed 10 months ago

originalnicodr commented 11 months ago

Depending on the service we end up choosing we might need to create some pipeline to handle this.

If we end up using a single service to host the bot and the images, it would be as easy as just downloading the images, putting them on the service storage, and getting/generating a public access link to put on the JSON database instead.

However, I wouldn't let how "easy" it is to upload something to this service be a deciding factor when choosing it. I am sure we will be able to power through it.

Blocked by

originalnicodr commented 10 months ago

Turns out Backblaze SDK was super easy to set up and use, so we did a minimal script to test it and it worked wonders.

def upload(file_name):
    local_file_path = f'./{file_name}'
    b2_file_name = f'{BACKBLAZE_HOF_FOLDER_NAME}/{file_name}'

    bucket = b2_api.get_bucket_by_name(BACKBLAZE_BUCKET_NAME)
    uploaded_file = bucket.upload_local_file(
            local_file=local_file_path,
            file_name=b2_file_name,
    )

Here are the docs of the function we used.