我有一个上传和下载图像文件在谷歌驱动器通过使用Django构建的网络应用程序的要求。我已经尝试使用Django Google Drive Storage API,它似乎可以在保存文件时工作。但我不知道文件保存在哪里以及如何读取文件。如果任何人有使用Django的经验,google drive API或有在google drive中存储文件的建议将是非常有帮助的。
谢谢。
发布于 2021-07-29 12:23:35
如果您使用模型来上传图像文件,则如下所示:
class Imageupload(models.Model):
imagefile= models.ImageField(upload_to='img',blank=True,storage=gd_storage)
views.py文件如下所示:
lst=Imageupload.objects.all()
url_for_first_imagefile=lst[0].imagefile.url #used to display or download the image in template
然后,您可以使用imagefile.url属性直接访问它们。
https://stackoverflow.com/questions/63460794
复制相似问题