static images not served after deployment to heroku - python

I'm working on a small web application built with python and plotly-dash. Everything worked fine locally and so I deployed the code to Heroku. This also worked fine except for 2 out of 17 static images in the assets folder that won't get served after deployment. The error message is:
Failed to load resource: the server responded with a status of 404 (NOT FOUND)
The initial settings for plotly-dash were set to 'serve assets locally'. So I tried to serve them from an S3 bucket with the same result. These two images can't be found on the server.
One more piece of information. I saw that the file extension for both of these files was '.JPG' instead of '.jpg' for all the other files that are showed correctly. I saved them under XY.jpg but this didn't solve the problem either.
Any ideas what might be the problem here? I honestly run out of ideas. The code can be found here and the website is hosted here Click on 'Analyze' and 'Show me more details' to get to the problematic page.
I appreciate every input. Thanks inadvance.

I finally found the solution. Even though I changed the file extensions from 'JPG' to 'jpg' locally this change didn't make it to GitHub. I ended up converting the files to PNG format, adding and referencing them in the code and they finally showed up after deployment.

Related

Images not loading when deploying Django app to Heroku

I deployed my app to heroku: https://doggos-only.herokuapp.com/
The images on the Dog Images link work locally, but they do not work on the deployed version. The only useful error I'm getting is: cj_eOAaboi.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
My best guess is that it has something to do with the file path, but I'm not sure. I've tried looking around the web for a solution but have been unable to find one. Looking for any help, here is the repo: https://github.com/jpchato/doggos_only_project
I'm deploying from the deploy_branch in my repo.
That's because media files (Those files uploaded by the user) in heroku are not persistent, that means that after a certain time all the media will be erased.
I strongly suggest you to use a media CDN like cloudinary or amazon s3.
I wrote a post on how to setup a media CDN with cloudinary for free and you can access it right here
Django Tutorial: Set up Media files in Deployment for FREE

How to fix image is not showing in heroku deployed django app

I have a Blog created with Django 3.x. When I run the project on my local server then it works fine. So, I deployed my project to heroku and here is the link bblog-shovon.herokuapp.com/. Then the project was working fine. My project git link https://git.heroku.com/bblog-shovon.gitThen I created a post and then I gave it a thumbnail and finally everything was fine. But, After sometime when i revisit the site then every image were gone. I didn't found them. And when I tried to open the image on another tab then it shows this Error message screenshot. When I am writing this question then I created a new post and after publishing this this posts image is working. But, older image is not working.
Then, How can i fix this problem? Please help me!!
Heroku flushes the filesystem to the latest commit. So you will have to use third-party plugins such as AWSBucket, etc.
With Heroku the filesystem is not persisted so you will lose media files occasionally. Use S3 or some other provider to store your user-uploaded media (also your static files if you want, otherwise use whitenoise). Django-storages makes it very easy.

Large Uploads in Django

I am working on a cookiecutter-django project that requires users to be able to upload files in the .5-1gb size range. From what I understand when uploading files that are larger then 2.5Mbs django uses the TemporaryFileUploadHandler to first upload the file to the tmp directory and then to then transfer them to the media directory. However when I try to upload a larger file my site just hangs, I don't see any files come into the tmp directory, and I see no errors in the logs.
Is there some setting I need to turn on to instruct django to use the TemporaryFileUploadHandler? Or is there some way to possibly figure out where the site might be getting hung up? I am currently building out this project locally so I have full control over my environment.
I am using Python 3.4.5 and django 1.10
UPDATE 1
I have tested uploading files of 5mb, 10mb, 20mb, and 30mb they all upload fine. The file I am having issues with is 873mb.
UPDATE 2
After more debugging I have found that when up loading a large file to my site it gets as far as the get_form method on my view class. After that I am not sure what is called. I have been slowly adding logs at each step in the hopes of figuring out where it is stuck.

Deploying Django - Most static files are appearing except images

Most of my static files on my newly deployed Django website are working (CSS), but not the images. All the images are broken links for some reason and I cannot figure out why. I am serving my static files via Amazon AWS S3.
I believe all my settings are configured correctly as the collectstatic command works (and the css styling sheets are up on the web). What could be the problem?
It's probably impossible to give an accurate assessment with the limited info on your setup. If your css files are working what folder are they sitting in on your server?
Why not have images folder in the same directory and set that directory to your MEDIA_URL in your settings.py file?
In your browser check your images full path and compare that to your CSS files, where are they pointing, do you have a directory on your server where they are supposed to be? are you receiving an access denied if you try to directly put in that image url into your browser?

cant download files uploaded tree.io

All the files I upload to the tree.io tickets, projects, etc cannot be downloaded,
I am getting a 404 error.
I am running tree.io in a cantos 6 box.
any ideas to get this working please ?
after sometime found a solution for this.
i had to define the MEDIA_ROOT as an absolute URL in the settings.py
when i went to static/media there was no folder called attachments, i had to make one and give it the correct permissions for python can write to that folder.
this worked for me.

Categories