external request for a file gives 404 |
Hi Team,
In our ci3 app we supply an external service with a web_url so they can take a copy of one of our files and analyse it before giving us a decision about its suitability for our site. In ci4 I have used exactly the same idea but the 3rd party is saying they receive a 404 response so we are not getting good responses. If I try to view the file in question by using the url I too get 404 but with a clue that the GET route is not defined. eg https://www.mysite.com/images/uploads/te.../image.jpg I have reviewed the routing docs and the smart file handling docs but am a bit mystified about how to enable this file to be retrieved externally. I'm sure its easy but I cannot find the magic bullet ... yet. Any clues appreciated, thx Paul PHP Code: Run - php spark Routes What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
OK I have run the spark command. Nice table of all my defined routes.
How do I specify a route so that someone can read/copy a specific file? (or more generally and file written to a temporary directory with a random file in it)
Hi Team, its been a while since I posted because I have been trying to solve this issue. I haven't yet.
The latest situation is I now have a simple controller: PHP Code: <?php The actual images are stored away from the public folder because I wasn't sure if the local .htaccess was causing me a problem. Many thanks to SO article and contributor. I send off a request that includes the url "https://imageRender/tmpfolder/image_file" to our service provider (WebPurify) and they in turn use it to try to get the image for their consideration. However, I keep on getting 500 internal server errors when they request the image, and I have spent hours trying to figure out what is going wrong. I can see the images successfully in different browsers. I'm missing something quite subtle here. Perhaps its a headers issue? GET scheme https host www.goodnewsbig.com filename /imageRender/5bctoYptxum0/IMG_1886.JPG Address 94.76.252.125:443 Status 200 OK VersionHTTP/1.1 Transferred50.28 kB (49.43 kB size) Request PriorityHighest DNS ResolutionSystem Cache-Control no-store, max-age=0, no-cache Connection Upgrade, Keep-Alive Content-Security-Policy default-src 'self' https: 'unsafe-inline'; style-src 'self' https: 'unsafe-inline';font-src 'self' https:;img-src https: data: blob: Content-Type image/jpg; charset=UTF-8 Date Tue, 27 May 2025 13:26:54 GMT Keep-Alive timeout=5, max=100 Permissions-Policy geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=() Referrer-Policy same-origin Server Apache/2.4.63 (Ubuntu) Set-Cookie HttpOnly;Secure Strict-Transport-Security max-age=15768000 Transfer-Encoding chunked Upgrade h2 Vary Origin X-Content-Type-Options nosniff X-Download-Options noopen X-Frame-Options SAMEORIGIN X-Permitted-Cross-Domain-Policies none X-XSS-Protection 1; mode=block Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate, br, zstd Accept-Language en-GB,en;q=0.5 Cache-Control no-cache Connection keep-alive Cookie HttpOnly; GNB_cookies=dismiss; HttpOnly; GNB=39a67adc6966f3755346e4f87cb9f52e Host www.goodnewsbig.com Pragma no-cache Priority u=0, i Sec-Fetch-Dest document Sec-Fetch-Mode navigate Sec-Fetch-Site none Sec-Fetch-User ?1 Upgrade-Insecure-Requests 1 User-Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0 I have no idea if its a CI4 issue but thought I would ask anyway. regards, Paul
Try the inline download method instead of creating your own response and see if that works for you.
PHP Code: <?php (05-27-2025, 10:17 AM)grimpirate Wrote: Try the inline download method instead of creating your own response and see if that works for you. OK tried that. In my own browser it downloads the image and I can open it and see it. However when WebPurify try to get the image for moderation I see this in the logs: c2-54-176-221-19.us-west-1.compute.amazonaws.com - - [27/May/2025:19:06:37 +0100] "HEAD /imageRender/dtPWxMe3Feax/IMG_1887.JPG HTTP/1.1" 404 4178 "-" "python-requests/2.18.4" ec2-54-176-221-19.us-west-1.compute.amazonaws.com - - [27/May/2025:19:06:37 +0100] "GET /imageRender/dtPWxMe3Feax/IMG_1887.JPG HTTP/1.1" 404 5608 "-" "python-requests/2.18.4" Any ideas please? |
Welcome Guest, Not a member yet? Register Sign In |