Skip to content Skip to sidebar Skip to footer

Save Image Generated With Reportlab In My Media Folder (in Amazon S3)

I implemented this library for generate barcodes images (http://kennethngedo.wordpress.com/2014/02/07/how-to-generate-barcode-in-django-using-reportlab/) Everything works fine, the

Solution 1:

I had a similar Problem but without the Amazon S3 part. For me it was really easy to create a new File in the media folder. I could simply use default_storage to get the path to the media folder:

from django.core.files.storage import default_storage
import os

# Get the path to the barcodes folder in the media folder# check if the folder exists and create it if not

folderPath = default_storage.path('barcodes')
ifnot default_storage.exists('barcodes'):
    os.mkdir(folderPath)

Since django-skel seems to be using a django-storage backend for Amazon S3 this should also work for your setup. If the Amazon S3 storage backend is not the default storage backend, you might have to use the S3Storage class directly.

Post a Comment for "Save Image Generated With Reportlab In My Media Folder (in Amazon S3)"