Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update download link does not work when masking the url #525

Closed
Yehi opened this issue Mar 31, 2023 · 3 comments
Closed

Update download link does not work when masking the url #525

Yehi opened this issue Mar 31, 2023 · 3 comments

Comments

@Yehi
Copy link

Yehi commented Mar 31, 2023

Hey,
I have a plugin that receives updates from a file on my server and it works great.
I use – https://github.com/YahnisElsts/plugin-update-checker
My problem is when I try to change the file link to a masked link the update fails. The link behaves like a downloadable file but in practice it fails.
for example:
https://example.com/download/file.zip – works great
https://example.com/wp-json/my-end-point/v1/download – does not work
I added the headers:

header("Content-Type: application/octet-stream");
header('Content-Type: application/zip');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="file.zip"");
readfile('https://example.com/download/file.zip');
When you enter the link https://example.com/wp-json/my-end-point/v1/download, the file downloads properly through the browser.

The idea is that I can verify before downloading the file
How can I solve this?

@YahnisElsts
Copy link
Owner

Can you elaborate on "update fails"? Are there any error messages when that happens? Tip: If you see an update notification on the "Plugins" page, you can right-click the "update now" link and open it in a new tab to install the update in a way that will also display more information about the update process. Also, you could use something like Log HTTP Requests to see what response WordPress gets when it tries to download the update.

@Yehi
Copy link
Author

Yehi commented Mar 31, 2023

found the problem,
There is actually no problem with the code.
The problem is that I send the request to the link of the same website. When I update the plugin, the site automatically goes to maintenance, so the API of that site is closed and the error is received.
When I do the update from another site, of course everything works fine.
problem solved

@Yehi Yehi closed this as completed Mar 31, 2023
@ddur
Copy link

ddur commented Apr 25, 2023

@Yehi

found the problem, There is actually no problem with the code. The problem is that I send the request to the link of the same website. When I update the plugin, the site automatically goes to maintenance, so the API of that site is closed and the error is received. When I do the update from another site, of course everything works fine. problem solved

This may be the cause of my issue #489

I'm using endpoints API in my server implementation too.

Fix: When download is requested from same site, just provide local path instead of link (see the issue above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants