pcloud-sdk-js
pcloud-sdk-js copied to clipboard
pcloud Can't download file
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."}
See the other thread: https://github.com/pCloud/pcloud-sdk-js/issues/4#issuecomment-439262472
I saw that. I want to check that it is not possible to download the file with js sdk
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.
It helps. Thanks!
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.
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.
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.

You're going to need a proxy like what's mentioned here, but one you're hosting yourself, I believe.
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).