I have a Django web project that is using Amazon S3 for media files. The file upload is happening async direct from the browser.
I need to create some thumbnail images for each file that is uploaded. I found a tutorial for how to do this using AWS Lambda (which I've never used before) but seems like the future of web.
The only issue I am trying to figure out in my head is: how I will update my database back on the django web server with the information for the newly created thumbnail images? I intend to create a new database model (thumbnails) that will store the URL and tie the thumbmail to the main image information.
The only thing I have come up with is to expose a url on my web app to accept HTTP requests (assuming lambda can send HTTP requests). So when the lambda function completes a thumbnail image, it will send the request to my web app with the information for the newly created thumbnail image using POST or PUT.
The thing I don't like about this approach is that it won't work when developing locally. Does anyone have any experience using Lambda to create thumbnails and then communicating back with your web server which differs from my proposed plan?
Related
I am working in building a real estate application
using spring boot java and the application in the aws server and images uploading in s3 bucket
what i want is that when the user add a propery if the the user close the app
the uploading task continue in the background and notify when complete
I found a resumeUpload method looks like just you want here.
Also an upload example in the aws s3 document.
Wish this help.
(Disclaimer : I'm just getting started with Django, and with web dev in general)
I have a backend app that stores different kinds of resources. Some are public and some are private. The application is accessible only to identified users. A GraphQL API allows me to access the resources.
On another server, I'd like to create a website that will be accessible to everyone. I want to use Django to create it.
The website will display a list of resources tagged as "public" in the backend app, with a pagination system and, say, 20 resources by page. The CSS will differ from the backend app and there will be a search section.
From what I understand, I should be able to retrieve the data through the GraphQL API, but I'm a bit confused here. All the documentation and tutos I can find about Django and GraphQL seem to be about setting up a GraphQL API server with Django. All I want to do is to build custom queries and to display them on my different html pages.
How can I do that? Where should I start?
You should connect your project with a GraphQL client. As per my research, I have found that there are implementations and examples for graphene-mongoengine in Flask (Flask has a direct GraphQL client).
Mongoengine Flask with GraphQL Tutorial
For Django you can check this out
Edit- I was able to get the data from my database with python-graphql-client. Now I am able to display them in my template.
Let me know if this helps
I have set up an S3 bucket on AWS where I upload my sensitive ‘media’ files from my Django DRF + React app. The files are not public. I use boto3 and Django-storages for that and the upload process works fine. I can also download the files for report generation from backend to return PDF response.
I would now like to display those files one by one from frontend. It seems like I now have two options:
Create a route in Django API/urls to handle media requests and point the app to the media directory. This way, the AWS login is handled by the backend server. This seems to beat the point of using a CDN as all media requests would go via the backend server?
Incorporate login credentials to React front end. This seems insecure.
What would be the recommended way to achieve this? I can’t seem to find the required information.
Thank you.
I have a decoupled applications build with Django 2, an API with DRF and an Angular 6 frontend application. I want to enable users to upload photos for their profiles, and probably in the future some pdfs, and after some research I figured out that the most convenient thing to do would be to store these files in an Amazon S3 bucket.
I have found numerous resources about how to upload files to an S3 bucket on both, Angular and Django, and now I was wondering what would be the best approach to do this in my decoupled application: should I manage it on the frontend and not use my backend at all? or should I pass the file from my angular to my Django app and then upload it to the bucket from there?
Some pros and cons of both approaches? It's my first time doing this and I haven't been able to find many resources for decoupled applications.
Any help is welcome! thanks!
The best practice
Anything related to data must be managed by your backend i.e Django, Angular is just a client.
You should pass the file from angular to Django app and then upload it
to the s3 bucket from there
Cons using client
Suppose in future, if you will develop mobile apps to consume your rest APIs then you need to rewrite the whole management there also.
You have to keep your s3 bucket API keys on the client and it is easily accessible to hackers.
dist folder size will be going to increase that will affect the load time of your site
If you are uploading files from client to S3 bucket, it will use the user's internet and in most of the cases it is slower than your sever's internet
I tried to add a YouTube video in article content, but it alway failed to upload the video link because YouTube is blocked in my country. So I built a HTTP proxy to watch YouTube, how could I tell the wagtail application to use my HTTP proxy while fetching YouTube embed metadata?
As far as I understand, your server and your users are behind a firewall that blocks access to YouTube. So there is two problems to solve:
Your Wagtail app should be able to access https://www.youtube.com/oembed to fetch metadata and iframe code to embed (see the example response).
Your users should be able to access youtube servers to watch videos.
To solve the first problem you can use a custom embed finder. You can find some information on how to add a custom embed finder the Wagtail's documentation.
Your embed finder should recognise youtube urls and send requests to fetch meta info through the proxy.
The second problem should be solved on the client's side (the client's browser should use proxy) or you should transparently proxy traffic youtube <-> your users somehow. It's not really Wagtail related issue, so I'll leave it with you.