Heroku django项目只读文件系统

时间:2022-09-11 16:48:14

I'm deploying django project on heroku, it works fine, but in django admin, when i'm trying to upload image i got error:

我正在heroku上部署django项目,它运行正常,但在django admin中,当我尝试上传图像时出现错误:

OSError at /admin/blocks/block/add/

[Errno 30] Read-only file system: '/home/goldwedd'

2 个解决方案

#1


8  

This is by design.

这是设计的。

Your app is compiled into a slug for fast distribution by the dyno manager. The filesystem for the slug is read-only, which means you cannot dynamically write to the filesystem for semi-permanent storage. The following types of behaviors are not supported:

您的应用程序被编译成一个slug,供dyno经理快速分发。 slug的文件系统是只读的,这意味着您无法动态写入文件系统以进行半永久存储。不支持以下类型的行为:

  • Caching pages in the public directory
  • 在公共目录中缓存页面
  • Saving uploaded assets to local disk (e.g. with attachment_fu or paperclip)
  • 将上传的资源保存到本地磁盘(例如使用attachment_fu或paperclip)
  • Writing full-text indexes with Ferret
  • 用Ferret写全文索引
  • Writing to a filesystem database like SQLite or GDBM
  • 写入SQLite或GDBM等文件系统数据库
  • Accessing a git repo for an app like git-wiki
  • 访问git-wiki等应用程序的git repo

https://devcenter.heroku.com/articles/read-only-filesystem

https://devcenter.heroku.com/articles/read-only-filesystem

If you want to upload files, you need to do so to S3 or any of the other storage backends supported by django-storages.

如果要上载文件,则需要对S3或django-storage支持的任何其他存储后端执行此操作。

#2


0  

Yes, you can not upload media files at heroku. Only via git you can deploy things and if you deploy static or media files they will be available with some workarounds.

是的,您无法在heroku上传媒体文件。只有通过git才能部署内容,如果部署静态或媒体文件,则可以使用一些解决方法。

For live file upload you should consider to use an external service like Amazon S3. There is an excellent library for django to deal with it (its also suggested by the heroku dev site, as far as I remember): django-storages

对于实时文件上传,您应该考虑使用Amazon S3等外部服务。有一个很好的django库可以处理它(据我所记,它也是由heroku开发网站建议的):django-storages

#1


8  

This is by design.

这是设计的。

Your app is compiled into a slug for fast distribution by the dyno manager. The filesystem for the slug is read-only, which means you cannot dynamically write to the filesystem for semi-permanent storage. The following types of behaviors are not supported:

您的应用程序被编译成一个slug,供dyno经理快速分发。 slug的文件系统是只读的,这意味着您无法动态写入文件系统以进行半永久存储。不支持以下类型的行为:

  • Caching pages in the public directory
  • 在公共目录中缓存页面
  • Saving uploaded assets to local disk (e.g. with attachment_fu or paperclip)
  • 将上传的资源保存到本地磁盘(例如使用attachment_fu或paperclip)
  • Writing full-text indexes with Ferret
  • 用Ferret写全文索引
  • Writing to a filesystem database like SQLite or GDBM
  • 写入SQLite或GDBM等文件系统数据库
  • Accessing a git repo for an app like git-wiki
  • 访问git-wiki等应用程序的git repo

https://devcenter.heroku.com/articles/read-only-filesystem

https://devcenter.heroku.com/articles/read-only-filesystem

If you want to upload files, you need to do so to S3 or any of the other storage backends supported by django-storages.

如果要上载文件,则需要对S3或django-storage支持的任何其他存储后端执行此操作。

#2


0  

Yes, you can not upload media files at heroku. Only via git you can deploy things and if you deploy static or media files they will be available with some workarounds.

是的,您无法在heroku上传媒体文件。只有通过git才能部署内容,如果部署静态或媒体文件,则可以使用一些解决方法。

For live file upload you should consider to use an external service like Amazon S3. There is an excellent library for django to deal with it (its also suggested by the heroku dev site, as far as I remember): django-storages

对于实时文件上传,您应该考虑使用Amazon S3等外部服务。有一个很好的django库可以处理它(据我所记,它也是由heroku开发网站建议的):django-storages