Django: Upload database associated file to remote server - django

Hello community of stack overflow.
Im having a big problem.
Well this is my scenery: I have two projects of Django, and the users model have a ImageField, When I create in both Porjects the users I want upload this field to another server, for example I have a Droplet in DigitalOcean just with apache, and I want upload all the media data in this server!
Thanks in advance!

I finally used the storage application, at the end, the system is uploading media files to AWS S3!

Related

Migrating Django app to use online media storage

I have a Django app running on a server. Currently user uploads are stored on the server filesystem.
I already know how to set up S3 storage. What is the best way to migrate existing uploads to S3 without breaking the API and having existing uploads still available?
These files are served to the front end in two ways:
Directly through a /media/path/to/upload endpoint:
/media/<path> django.views.static.serve
Through a viewset:
/api/v1/users/<user_pk>/items/<item_pk>/attachments/<pk>/ project.app.views.ItemAttachmentsViewSet
Does the following make sense:
Change the storage backend
Go through all model objects
Save each model object to get the files uploaded
Have /media/path go to a new view that will serve the files similar to how ItemAttachmentsViewSet does it.
? Or is there a better way?
The procedure outlined in the question was what I ended up doing, with the exception of step 4 which turned out to be unnecessary.

How to updating data after deploying shiny app on shinyapps.io

I need help to learn how to update my data after deploying on shinyapps.io.
Raw data import from URL as the CSV format type.
I would appreciate if somebody knows or provides documentation or example as a walkthrough.
Thank you,
shinyapps.io is containerised. Any data you upload to an instance of the app will be lost when that instance terminates. The only way to make data available to more than just the current instance of the app is to bundle it with the package itself.
As an example: User1 uploads a file to your app. They can use the file until they close ther app down. Next time they use the app, they will need to upload the file again. User2 is using a different instance of the app at the same time as User1. User2 will NEVER have access to the file uploaded by User1.

Heroku: Django database file lost on every dyno restart

I deployed a Django app on Heroku. I have some models and inserted some data to the database (SQLite database). But, when I tried to access the data after certain time, it showing an empty database. I found a problem similar to my issue here ->django heroku media files 404 error and I understood that, I should keep my Media files somewhwere else. Here my problem is with database and my question is, can I prevent my SQLite database from this data loss ?
There is nothing you can do about this, short of storing the database on some other service like Amazon S3. Heroku has ephemeral storage: https://devcenter.heroku.com/articles/sqlite3#disk-backed-storage
However, Heroku also comes with free persistent PostgreSQL. So I would advice you to use that instead.

Where should I store user uploaded pics and files

I am working on a django app to store user pics and photos.
What is the optimal approach to store individual user media.
File Sizes are no more than 5MB.
The data is persistent.
The approach i have in mind is:
On form data submission, Upload it to an FTP server using django-storages.
Store the url and fetch it via http later for user.
How to save upload files to another server
I have seen the answers and I don't know what type of queue needs to be used.
you'd usually save the file locally and then latter upload it to some cloud service asynchronously, preferably using something like django-celery
see this answer

Sitecore - not publishing media library

We are using Sitecore 6.5 and have a multi-site Sitecore solution (with lots of library code we have inherited)
Publishing the Media Library by item from Staging to Production but we are not seeing the image on the web.
The images are in the web database and the path to the images in the web site is good.
Error we are getting when the file is requested (same in browser window address bar) is http://domainname/error?aspxerrorpath=/~/media/OSS/Images/WaterAndWildlife/myimage.jpg.
There is no media prefix in the web.config
Any idea?
....Looking into it now but site is going live tomorrow so help very appreciated! Help!!
We faced a similar problem when, in production, media files were not published which resulted in 404 errors.
Solution: The problem was that media files were not saved to the database because a file path was provided with the Sitecore media files while uploading.
So the images were saved on the file system instead of in the database. But based on our web.config configuration we were fetching images from the database.
If you are facing a similar issue, just download the media image, remove the file path, and save it. Then re-upload the same image, save and publish the image.
Hope your problem will be solved.
One question, are these staging and production environments separate code files? if they are, what is the setting in your web.config for the settigns UploadAsFiles? because if that's true it will store them on server and the images will be on staging but not on prod. But usually if this setting is true and the files are getting stored in file system, specially in CM/CD environment it should push the physical files on publish as well, but sometime there might be other issues going on like permission etc..... and the files cant get to the destination.
"<setting name="Media.UploadAsFiles" value="false">"