如何从Django的数据库中下载Blob字段中的数据? [英] How to download data in a blob field from database in django?

查看:349
本文介绍了如何从Django的数据库中下载Blob字段中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中有一个包含一些数据的Blob列,如何在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

推荐答案

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

这篇关于如何从Django的数据库中下载Blob字段中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆