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

pcloud Can't download file

Open MilosDjonovic opened this issue 5 years ago • 8 comments

I've try example for download: https://github.com/pCloud/pcloud-sdk-js/blob/master/examples/download.html and it does not work. When I clikc on "Get token", files are listed, but download button does not work. Console.log: Uncaught (in promise) {result: 7010, error: "Invalid link referer."}

MilosDjonovic avatar Nov 14 '18 12:11 MilosDjonovic

See the other thread: https://github.com/pCloud/pcloud-sdk-js/issues/4#issuecomment-439262472

sorentycho avatar Nov 16 '18 06:11 sorentycho

I saw that. I want to check that it is not possible to download the file with js sdk

MilosDjonovic avatar Nov 16 '18 06:11 MilosDjonovic

From what I can tell looking through the code (and the error you recieved), the JS SDK is using the same HTTP API we've been trying. So I think, even though the SDK includes a browser module, it's not possible.

I'm porting my app to Dropbox, which I've just verified to allow file downloading in the browser on an arbitrary site. Dunno if that helps you or not.

sorentycho avatar Nov 16 '18 07:11 sorentycho

It helps. Thanks!

MilosDjonovic avatar Nov 16 '18 07:11 MilosDjonovic

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

The issue is that the method downloadfile also uses the getfilelink method which "can't be used from web applications. Referrer is restricted to pcloud.com". See #4.

igneosaur avatar May 24 '20 11:05 igneosaur

Yeah, it looks like that download.html file should've been removed. I got the token part working well (see this PR), but then ran into your run-of-the-mill CORS errors.

As @igneosaur remarks, getfilelink only works for pCloud.

This method can't be used from web applications. Referrer is restricted to pcloud.com.

You're going to need a proxy like what's mentioned here, but one you're hosting yourself, I believe.

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

I have a PWA app which gets access to its app folder only and is used to backup and (was hoping) restore the data and settings to/from pCloud. This is pretty bad news, finding it out only once coming to the point where a download needs to be made from the app. Subscribing to the issue in hope things improve (and soon).

alensiljak avatar Sep 13 '22 08:09 alensiljak