Managing server files in django - python

I see various bits of information in the docs, but I can't seem to form the complete picture.
I wish to hold various text, audio and video files on the server. At the moment I'm not planning to add user upload support but it would be nice to expand to that in the future.
I just don't understand where to start and what to do. Where do I save those files on the server? What is the best way for django to interact with those files?
I hope that you can help me with the confusion :)

Related

File Upload Handling with Pynecone

I want to create a file sharing website in with pynecone. Is there a go-to way to upload files and save them on the server?
The documentation says to use React components if there aren't any Pynecone specific components, but I wanted to know if Pynecone can handle files uploads on its own.
This is not available yet, but is a high priority feature to add. There is an open ticket here. It should be available soon.

Setting Up S3 with Heroku and Django with Images

so I currently have my static files (js and css) just being stored on Heroku which is no biggie. However, I have objects that I need to store multiple images too and be able to get those images on request. How would I store a reference to those images?
I was planning to use a S3 Direct File Upload using these steps on Heroku here. Is this also going to be the best way for me to do so?
Thank you in advance.
I don't think setting up static (css,js,etc..) or media (images, videos) to be stored on S3 has anything to do with Heroku or where you deploy. Rather, its just making sure Django knows where to save the files, and where to fetch them. I would definitely not follow that link, because it seems confusing and not helpful when working with Django.
This tutorial has really helped me, as it will show you how to set all of that up. I have gone through these steps and can confirm it does the trick. https://simpleisbetterthancomplex.com/tutorial/2017/08/01/how-to-setup-amazon-s3-in-a-django-project.html
While I've gone this route in the past, I've recently opted to use Digital Ocean's one-click app - Dokku. It's based on Herokuish. I then use Dokku's persistent storage to take advantage of the 25 gigs of storage on DO's smallest, $5/month, plan. I wrote a guide to this here.

Standalone Desktop App with Centralized Database (file) w/o Database Server?

I have been developing a fairly simple desktop application to be used by a group of 100-150 people within my department mainly for reporting. Unfortunately, I have to build it within some pretty strict confines similar to the specs called out in this post. The application will just be a self contained executable with no need to install.
The problem I'm running into is figuring out how to handle the database need. There will probably only be about 1GB of data for the app, but it needs to be available to everyone.
I would embed the database with the application (SQLite), but the data needs to be refreshed every week from a centralized process, so I figure it would be easier to maintain one database, rather than pushing updates down to the apps. Plus users will need to write to the database as well and those updates need to be seen by everyone.
I'm not allowed to set up a server for the database, so that rules out any good options for a true database. I'm restricted to File Shares or SharePoint.
It seems like I'm down to MS Access or SQLite. I'd prefer to stick with SQLite because I'm a fan of python and SQLAlchemy - but based on what I've read SQLite is not a good solution for multiple users accessing it over the network (or even possible).
Is there another option I haven't discovered for this setup or am I stuck working with MS Access? Perhaps I'll need to break down and work with SharePoint lists and apps?
I've been researching this for quite a while now, and I've run out of ideas. Any help is appreciated.
FYI, as I'm sure you can tell, I'm not a professional developer. I have enough experience in web / python / vb development that I can get by - so I was asked to do this as a side project.
SQLite can operate across a network and be shared among different processes. It is not a good solution when the application is write-heavy (because it locks the database file for the duration of a write), but if the application is mostly reporting it may be a perfectly reasonable solution.
As my options are limited, I decided to go with a built in database for each app using SQLite. The db will only need updated every week or two, so I figured a 30 second update by pulling from flat files will be OK. then the user will have all data locally to browse as needed.

Saving emails for later view

I need to save emails I receive so that the user can view them later on. They need to be saved in such a way that the images will remain even if their links a re broken (e.g. for the images that are link and not attachments, upload them to S3 and change the links to point to them).
Can anyone recommend a library that will help me achieve that?
I was thinking of two approaches:
1) Save the email to PDF - but I have no idea how to make it correctly include the images.
2) Save the original email and render it on the client, but then it doe snot show the attached images.
Any one of those will do with preference to the first option. If its the first option then I can write it on my RoR server or as an external Python service. If its the sercond I have to write it to work on RoR.
I am aware that this question is similar to: Best way to save email, including images and HTML data, using Java Mail API?
but I need to do it on Rails not Java.
Thank you!
Why not just have an auto-forwarder to a separate account? That way they would effectively be bcc'd on everything you get. I know Gmail can easily do that with filters.
Another option is forwarding the emails to a 'read it later' service and let their api do the heavy lifting. Not sure if they keep the attachment, but it is worth a look.

How do you create a video file upload form with Django?

I want a user to be able to upload a video from their computer or record it right from their webcam, then fill out other information with a form. I'm writing this app with Django.
Recording directly from the web cam is not as simple as uploading an existing video file. You may need to look into one of the many video streaming protocols and handle that via a server such as red5. This approach would require the use of Flash or something similar.
The Django documentation should be able to help you handle file uploads:
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
Additionaly have a look at jquery uploadify. It's pretty useful for large file uploads because it display the progress of the download.

Categories

Resources