Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download data in a blob field from database in django?

Tags:

django

blob

I have a table in which I have a blob column containing some data, how can i download the blob content in django? I tried the solution mentioned here but it didn't work for me

like image 531
user2137817 Avatar asked Jul 29 '13 11:07

user2137817


1 Answers

def download_blob(request, id):

    contents = BlobModel.objects.get(id=id).blob_field

    response = HttpResponse(contents)
    response['Content-Disposition'] = 'attachment; filename=blob.bin'
    return response
like image 104
Thomas Avatar answered Sep 28 '22 04:09

Thomas