.github | ||
components | ||
config | ||
pages | ||
public | ||
styles | ||
utils | ||
.eslintrc | ||
.gitignore | ||
LICENSE | ||
next-env.d.ts | ||
next.config.js | ||
package-lock.json | ||
package.json | ||
postcss.config.js | ||
README.md | ||
tailwind.config.js | ||
tsconfig.json |
Discussion
Please go to our discussion forum for general questions and FAQs, issues are for bug reports and bug reports only. Feature requests may or may not be ignored, as I (@spencerwooo) am the only one maintaining the project, so I only prioritise features that I use.
Of course, I accept sponsors and donations :3
Demo
Live demo at Spencer's OneDrive.
Features
👀 File preview | 🖼️ Image preview | 🎥 Video and audio |
PDF, EPUB, markdown, code, plain text | Also in gallery mode | mp4, mp3, ..., play online or with IINA, PotPlayer... |
📄 Office preview | 📝 README.md preview | 📑 Pagination |
docx, pptx, xlsx, ... | Also renders code blocks, images with relative links, ... | For folders with 200 or more items |
🔒 Protected folders | ⏬ Multi-file download | ⏭ Proxied download |
Password protected routes and files, details down here ↓ | Compress and download multiple files or folders, details down here ↓ | Download files with streams proxied through Vercel Serverless, details down here ↓ |
... and more:
- Direct raw-file serving, proxied file serving ...
- Permalink copy, proxied download link copy ...
- Full dark mode support, style and website customisations ...
🍌 More importantly, it's pretty (●'◡'●)
Deployment
No time to write deployment documentation! Here are some quick hints, play around with caution! (I promise detailed docs are on the way.)
- Fork the project to your own account, as you will be maintaining your custom version of this project with your own configurations.
- Change configuration file
config/api.json
andconfig/site.json
according to your configs (see Configurations ↓). - Define environment variables inside Vercel:
REFRESH_TOKEN
,ACCESS_TOKEN
,CLIENT_SECRET
. - Deploy inside Vercel, profit.
The authentication tokens and variables are the same as what you configured in the onedrive-cf-index
project. Detailed documentations can also be found there (for now). This project is at its early stages, for discussions please, please, please post to the discussion forum.
Configurations
These configurations are subject to change before
v1.0
milestone.
Two configuration files are used for customisations - config/api.json
and config/site.json
.
config/api.json
- is used to define your API endpoints and tokens, and the path for your shared OneDrive folder.config/site.json
- is used for customising the website, such as the title, used Google fonts, site icons, contact info, etc.
A few things to keep in mind for config/site.json
:
icon
- is the website icon to the left of the title inside the navigation bar. It should be placed under/public/
and referenced here by its relative path.maxItems
- represents the maximum number of items that one directory lists, pagination supported. This is limited up to 200 items by the upstream OneDrive API.email
- is optional, and can be removed should you wish. However, I suggest adding some form of contact for your website.links
- is an array of{ "name": "xxx", "link": "xxx" }
. In the latest update, all brand icons inside font awesome is supported and the icon to render is based on thename
you provide. See the demo screen recording below. (The additional links in the demo video are generated automatically by GitHub Copilot and may not be my personal account.)
The rest of the configuration fields are self-explanatory.
These may interest you ...
🔒 Password protected folders
You can now specify a .password
under a folder, declare the directory's absolute path, to password-protect the route and all files inside.
-
Declare protected route inside
config/site.json
underprotectedRoutes
, for instance:"protectedRoutes": [ "/🌞 Private folder/u-need-a-password", "/🥟 Some test files/Protected route" ],
-
Add
.password
file under the root protected folder, redeploy your project on Vercel. Profit.
However, there are some caveats:
- Function is not entirely reliable and may be largely vulnerable to all kinds of threats. DO NOT use for protecting sensitive information.
- Protected files cannot be shared through
?raw=true
url parameters.
⏬ Multi-file and folder download
We use JSZip to download all files in-browser and compress them into file blobs, which are then downloaded to your device as a zip
file. This is extremely useful if a series of small files are to be downloaded, but it could be time consuming if used for bulk-downloading a few large files.
Folders are traversed and recursively fetched into the compressed zip. Multiple files or folders can be selected and downloaded side-by-side.
🖼 OneDrive as your website's image storage
Yes, it can be used as an image (or any kind of file) online storage, where the raw file link is exported and can be embedded into your blog or other websites. Images, videos, songs, PDFs..., you name it.
[nyan cat](https://drive.spencerwoo.com/api?path=/%F0%9F%A5%9F%20Some%20test%20files/nyancat.gif&raw=true)
⏭ Proxied download
In order to speed up (I doubt it would?) download speed when files are directly served on OneDrive servers, we can leverage a proxied download which relays the file download stream through Vercel Serverless first, then back to our own device.
You can download a file via this method by either clicking on the Proxy download
button beside the normal Download
button in file preview pages ...
... or craft the API request yourself:
GET /api/proxy?url=<URL_ENCODED_DIRECT_FILE_LINK>
Only thing to keep in mind is that the parameter url
should be a direct OneDrive file link that is URL encoded. An example is shown below:
https://drive.spencerwoo.com/api/proxy?url=https%3A%2F%2Fpublic.dm.files.1drv.com%2Fy4myMMSl7_RbMnKGsEh63emSTxRqfK74Ove5_k-zuKFv7Y_uet4FeuwI5X3NW8IjdkOlvoIRfq64XICJeHeZiRDBcnJuH-lfjZUQykrMM11xO9H3Z8GPRA9lfjjjdYXQAcMc2XYAr1Pnmod3PeEYoAKAArFEyLKvwk19iypsEDhXbl6L8-f1QxMGGlf6tboO0XijBdxtmV4oQJLmutVk44kETDC-16Sfj2--9erJfsH_W1EEddXUB-vEtpRoBM20srt
An
&inline=true
parameter is also accepted here, where the response headercontent-disposition
of the direct file stream from OneDrive is replaced fromattachment, filename*=...
toinline, filename*=...
. This only applies to PDF files with a headercontent-type
ofapplication/pdf
, so that the PDF returned can be viewed inside the browser, instead of being force downloaded.
Feature parity with original project: Proxied / raw file download.
Server-less?
Yes! Completely free with no backend server what-so-ever.
onedrive-vercel-index ©Spencer Woo. Released under the MIT License.
Authored and maintained by Spencer Woo.
@Portfolio · @Blog · @GitHub