简体   繁体   English

Django 使用 googledriveapi 在 google drive 中上传和下载文件

[英]Django upload and download files in google drive using googledriveapi

I am new to django and trying to create a web app to upload and download files to the google drive using gdriveapi.我是 django 的新手,并试图创建一个网络应用程序来使用 gdriveapi 将文件上传和下载到谷歌驱动器。 I have gone through the python quickstart for Google drive and tried the code in manage.py where it is working.我已经浏览了 Google 驱动器的 python 快速入门,并尝试了它正在工作的 manage.py 中的代码。

How to write the same code to obtain credentials and upload and download in the django app?如何编写相同的代码来获取凭据并在 django 应用程序中上传和下载? How to write the view and model in django to obtain credentials and upload files to gdrive?如何在django中编写视图和模型以获取凭据并将文件上传到gdrive?

for my model field I use file = models.FileField(upload_to='todo', storage=gd_storage, blank=True, null=True) , where todo is the app name.对于我的模型字段,我使用file = models.FileField(upload_to='todo', storage=gd_storage, blank=True, null=True) ,其中 todo 是应用程序名称。 For the view I simply used the generic ModelViewSet, where you can just serializer.save(file=self.request.data['file'])对于视图,我只是使用了通用 ModelViewSet,您可以在其中serializer.save(file=self.request.data['file'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM