pcloud-sdk-js icon indicating copy to clipboard operation
pcloud-sdk-js copied to clipboard

JS SDK "getfilelink" api does not work.

Open audiorecorder opened this issue 7 years ago • 9 comments

when i call "getfilelink" api on the web, An error occurs.

client.getfilelink(4130653400).then(function(resp){ }); https://api.pcloud.com/getfilelink?access_token=??????&fileid=4130653400&forcedownload=1 Error: {result: 7010, error: "Invalid link referer."}

Please fix this problem. and I also hope that the direct-download link supports CORS for XHR.

audiorecorder avatar Oct 23 '17 21:10 audiorecorder

Hello, This is not an issue with the SDK itself, but with the platform. Downloading files from the browser is not currently supported. Can you tell me more about your app and what you want to achieve?

Also, do you use other Cloud APIs and do you know how they work around this issue?

elanoism avatar Oct 27 '17 11:10 elanoism

Hello, I work with meteor js and I use Pcloud SDK in my project, I can download the file on my server side, but how can I download file from my client side page

Thank you

bundu1109 avatar Jul 09 '18 04:07 bundu1109

How to play a video on web client? Received 7010 when using gethlslink.

wangdaliu avatar Sep 10 '18 14:09 wangdaliu

This is not an issue with the SDK itself, but with the platform. Downloading files from the browser is not currently supported. Can you tell me more about your app and what you want to achieve?

That's really disappointing. An artificial limitation like this should be documented clearly, not left to be discovered when people have already made an investment in your tech on other platforms.

sorentycho avatar Nov 16 '18 02:11 sorentycho

The problem (I had the same after long work time) is that the api creates links to download files/images/etc for a determinated IP, so if you generate the link (as I made) from your server side (the link is limited to the server IP), so if you try to consume the link from the client side (as also I made), it doesn't work, because are not available.

And yes is really disappointed that this restriction is not documented in any place, and also that you cannot disable it. For me worked fine for weeks that I only tried in localhost, and when I was ready to publish it, boom, it doesn't work.

SirMartin avatar Nov 29 '18 14:11 SirMartin

I was actually generating download links and consuming them in the same place (I was using the API client in a SPA). If I ran it from localhost, everything worked well (and the API was nice and fast, too, unlike Dropbox), but I started getting "invalid referrer" errors when I tried to deploy anywhere else, indicating that it's not just a design issue but a deliberate, artificial restriction with an exception for local development and that it would have been less engineering to just allow browser clients to download files. That combined with the lack of documentation left a bad taste.

sorentycho avatar Nov 29 '18 18:11 sorentycho

Hi, Is there any workaround for the issue?

goutick avatar Sep 27 '20 15:09 goutick

Seems, what we need is to be able to generate the link on behalf of the client IP at server level. Can we pass the client IP in the request? Can we ask for that feature?

DCWizard avatar Dec 23 '21 04:12 DCWizard

Hello, This is not an issue with the SDK itself, but with the platform. Downloading files from the browser is not currently supported. Can you tell me more about your app and what you want to achieve?

Also, do you use other Cloud APIs and do you know how they work around this issue?

The example files seem to expect this to work -- see the download.html file in examples, though it, obviously, currently throws a CORS error (even after debugging the example). But it doesn't seem to expect to!

Use case: I would like to download music files and push their content into an audio tag, for example, to create a self-hosted player that doesn't require a middleware and can access pCloud directly.

And, you know, also so that the examples work as expected. :wink:

ruffin-- avatar Sep 06 '22 03:09 ruffin--