Python中文
首页
教程
问答
标签
搜索
登录
注册
djangstorages将FileField和ImageField上传到Dropbox
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>(Django 2.0、Django Rest Framework 3.8、python3.6、Django Storages 1.7、Dropbox 9.1)</p> <p>我试图将文件上载到我创建的Dropbox应用文件夹,但每次尝试都会遇到相同的错误:</p> <p><code>C:/TrainerPics/UI_4.png' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'</code></p> <p>在桌面的Dropbox仪表板上,我要上载到的文件夹显示为:</p> <p><code>Dropbox > Apps > DjangoAppNameHere</code></p> <p>这是我在<code>settings.py</code>中的设置:</p> <pre><code>STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage' DROPBOX_OAUTH2_TOKEN = 'some_token_here' </code></pre> <p>其中<code>storages</code>也列在已安装的应用程序中。下面是我要上载的模型字段:</p> ^{pr2}$ <p>我尝试过使用和不使用<code>/</code>字符,并使用<code>upload_to=DjangoAppNameHere</code>同时使用<code>FileField</code>和{<cd8>}字符,但没有成功。Dropbox的文档在django-storages包中相当少,并且没有描述如何设置一个字段使其工作。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>这是一个老问题,只是为了帮助那些可能有类似问题的人。在</p> <p>我有两种选择。在</p> <ol> <li><p>上传文件时使用linux机器。这将允许API上传您的图像,因为它可能是与服务器相同的文件系统。</p></li> <li><p>仅在服务器上使用DROPBOX API,在本地开发时使用本地文件存储。服务器运行在unix上,它不会产生错误。</p></li> </ol>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何添加虚拟方法
6 回答
如何添加表示整数的擦边字符串?
7 回答
如何添加要在Bokeh中使用的新font.ttf文件?
10 回答
如何添加要显示的矩阵XY轴编号和XY轴
8 回答
如何添加计数?
10 回答
如何添加计数器函数?
6 回答
如何添加计数器列来计算数据帧中另一列中的特定值?
2 回答
如何添加计数器来跟踪while循环中的月份和年份?
6 回答
如何添加计数并删除countplot的顶部和右侧脊椎?
8 回答
如何添加计时器wx.应用程序更新窗口对象的主循环?
5 回答
如何添加评论到帖子?PostDetailVew,Django 2.1.5
7 回答
如何添加评论拉梅尔亚姆
10 回答
如何添加诸如矩阵Python/Pandas之类的数据帧?
8 回答
如何添加谷歌地点自动完成到Flask?
6 回答
如何添加超时、python discord bot
6 回答
如何添加超过1dp的检查
10 回答
如何添加距离方法
3 回答
如何添加跟随游戏的敌人精灵
2 回答
如何添加路径以便python可以找到程序?
2 回答
如何添加身份验证/安全性以使用happybase访问HBase?
4 回答