Comments (12)
Side note: I've taken a look on this, but this is currently technically impossible due to raw.githubusercontent.com
returning 403 answers for OPTIONS
requests. However, those requests are inevitably made by the browser as preflight requests when making authorized calls with a bearer token attached.
This problem has been reported to GitHub relatively recently and at least they are aware.
However, until this changes, it will not be possible to do a purely client-side XHR request to private resources.
from download-directory.github.io.
Sounds good to me. Going to take a look soon — got another PR regarding error handling to land first (i.e. in a few seconds, be prepared 😁).
from download-directory.github.io.
That said, file contents could still be fetched via the GitHub API.
@fregante What would be your shot at this? Would you wait for GitHub to change their CORS behavior or make requests to the GitHub API? I'd happily implement anything. 😄
from download-directory.github.io.
That said, file contents could still be fetched via the GitHub API.
The GitHub API is limited (filesize) so this change would break downloading some larger files.
impossible due to
raw.githubusercontent.com
returning 403 answers forOPTIONS
requests
When does this happen? How are you passing the authorization? Pre-flight doesn't happen if we use simple requests
from download-directory.github.io.
Pre-flight does happen though if we're trying to authenticate with a bearer token (Authorization
header → not a simple request). This seems to be the only working authentication mechanism for our case.
When private files are shown in the browser, GitHub appends a token
GET parameter, however this does not seem to use regular access tokens — at least I'm getting 404 errors when I'm trying to use my access token in that place. (The token itself is fine, I can use it to e.g. grab the file when using it as a bearer token.)
from download-directory.github.io.
This seems to be the only working authentication mechanism for our case.
Yeah, HTTP authentication via URL and XMLHttpRequest.open
doesn't seem to be supported anymore. curl https://[email protected]/file.ext
works but not in the browser.
from download-directory.github.io.
Yep, those are the approaches I've tried as well. Seems that we're stuck with waiting for GitHub on this one.
from download-directory.github.io.
What do you think about implementing the API as a fallback for private repos? I think it'd have to check whether all the files are under 1MB as well; thankfully this info is available in the list
API call.
from download-directory.github.io.
We can use GitHub's blob API to fetch files up to 100 MB. However, we need the files' sha hashes for that. list-github-dir-content
actually fetches that data but does only return the file names.
To avoid redundant requests: Would you copy the list functionality over to this project or extend the list package with an option to include file details in the returned array?
from download-directory.github.io.
list-github-dir-content
exists only because of download-directory.github.io
. Since it doesn't have tests, download-directory.github.io
serves as a "live test."
In short, I'd extend it rather than copy it here.
If you want to send a PR there, we could add a flag to get the whole file object instead of just the path
- files.push(item.path);
+ if (getWholeData) {
+ files.push(item);
+ } else {
+ files.push(item.path);
+ }
Thoughts?
With a new flag however I'd suggest changing its API(s) to:
viaTreesApi({
user: '',
repository: '',
ref: '',
directory: '',
token: '',
getWholeData: false // new, name TBD
})
from download-directory.github.io.
Exactly how I'd have done it, nice. Going to submit a PR. Suggested names: detailed
, withDetails
, includeDetails
, withMetadata
, includeMetadata
?
from download-directory.github.io.
I don't like either of my suggestions. detailed
is not self-explaining enough IMO and all of the others indicate that metadata is sent alongside the file names, not in their place.
from download-directory.github.io.
Related Issues (20)
- CRLF in files are being converted to LF only HOT 5
- Add MIT License file HOT 4
- Action Required: Fix Renovate Configuration HOT 1
- What is the token? HOT 1
- Doesn't work for branches with slashes HOT 1
- Silently fails if token is missing HOT 5
- GitHub API format update HOT 1
- "No files to download" on large repos HOT 5
- Git LFS support HOT 1
- Can we re-use your code for our open-source community? HOT 3
- Failed to Load Resource: ERR_INSUFFICIENT_RESOURCES HOT 1
- Redirect to native zip URL when pasting a link to a branch, commit or tag
- Console errors on load
- Dependency Dashboard
- Getting error "Some files were blocked from downloading, try to disable any ad blockers and refresh the page." HOT 6
- RangeError: offset is out of bounds HOT 3
- Cannot download when filename contains hash (#) HOT 3
- File System Access API support HOT 3
- Serve tar.gz from server HOT 1
- Download of subfolder contains parent folder HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from download-directory.github.io.