Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes
download.html
[nearly] functional. The previous version did not work.I've made a few fixes and changes, including adding several convenience features.
downloadfile
functionfileid
was ignored; value had been hard-coded, which wouldn't work.console.log
s referenced "uploads"; now says download.localStorage
so that you don't have to get a token each time.access_token
was assigned but unused; it's now trivially used.locationid
was assigned but unused. It's saved tolocalStorage
now, but is essentially unused.createClient
, eg.listFiles
is now recursive through folders.lifeFiles
reads amaxdepth
from the ui to limit the folder depth used.2
to includeDemo Audio 2.mp3
if using aclient_id
with all folder access.client_id
.I realize this is slightly more complicated than a simplest case, but is the minimum I think you could give to demonstrate something approaching real-world usage. At just under 150 lines with html, it's not horrible. It is both folder & file listing plus download.
client_id
s and private vs. all folder accessI noticed that there were two
client_id
values being used throughout theexample
folder:client_id
of"3dunsTvYJsu"
, ALL FOLDERS accessclient_id
of"p1WznE2dEPm"
, private access onlyI included both in the code here, though the pCloundSampleApp
client_id
is hooked up by default. That does mean a user needs to put files in its app folder, which is why I added the message in case the app-specific folder is empty, as mentioned above.Strange server behavior
There are a few other things I'd clean up in a perfect world. I'd remove parent-scoped variables and change variable names to camelCase, for instance. But this seems to work fairly well, except...
The download doesn't seem to work! There's a CORS error, which means pCloud would need to change settings on the API side for this to work from a browser using the example code, even fixed.
It'll work from node, of course, or something else that isn't worried about CORS, but not from a browser on a non-pCloud domain.
I'll open an issue for that and reference it here. EDIT: Looks like it's been open a while, and the answer is that
getfilelink
isn't supposed to work with CORS. :sigh:If true, we should probably remove
download.html
, right?I've also noticed I have to sign-in twice in the OAuth interface to get a token with the examples. That's strange, though it doesn't prevent the app from eventually functioning.
Thank you!