https://github.com/github30/webdavjson
WebDAVJSON is a simple server-side script (PHP or Node.js) that gives you REST-style file management: list, upload, delete, download, all via JSON. Supports CORS, optional API key authentication, and file extension filtering.
https://github.com/github30/webdavjson
cors javascript mkcert nodejs php php7 php8 webdav webdav-server webdavjson windows
Last synced: 3 months ago
JSON representation
WebDAVJSON is a simple server-side script (PHP or Node.js) that gives you REST-style file management: list, upload, delete, download, all via JSON. Supports CORS, optional API key authentication, and file extension filtering.
- Host: GitHub
- URL: https://github.com/github30/webdavjson
- Owner: GitHub30
- Created: 2025-09-12T11:54:36.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-09-19T11:33:55.000Z (4 months ago)
- Last Synced: 2025-10-09T03:57:23.553Z (3 months ago)
- Topics: cors, javascript, mkcert, nodejs, php, php7, php8, webdav, webdav-server, webdavjson, windows
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/GitHub30/WebDAVJSON/actions/workflows/php-test.yml)
[](https://github.com/GitHub30/WebDAVJSON/actions/workflows/nodejs-test.yml)
# WebDAVJSON
WebDAVJSON is a simple PHP/Node.js script that provides file management APIs. It supports CORS, optional API key authentication, upload with extension restrictions, and JSON response for file listing.
## Features
- CORS support
- Optional API key authentication
- File listing (JSON)
- File upload, download, and delete
- Extension restrictions
- Single-file program
## Windows Setup
```powershell
winget install mkcert Node.js --silent
mkcert -install
mkcert localhost
node index.mjs
# await fetch('https://localhost:8443/').then(r=>r.json())
# await fetch('https://localhost:8443/?filename=foo.txt', {method: 'PUT', body: 'foobar'})
```
## Linux Setup
```bash
wget https://raw.githubusercontent.com/GitHub30/WebDAVJSON/refs/heads/main/index.php
```
## API Endpoints
| Method | Path | Description |
|----------|-----------------------------|-------------------------|
| GET | /?filename=abc.txt | Download file |
| GET | / | List files (JSON) |
| POST/PUT | / | Upload file |
| POST/PUT | /?filename=abc.txt | Binary upload |
| DELETE | /?filename=abc.txt | Delete file |
## Usage Examples
### List files
```bash
curl http://localhost/
```
### Search files (partial match)
```bash
curl "http://localhost/?q=abc"
```
### Download file
```bash
curl -O http://localhost/?filename=abc.txt
```
### Download file (as attachment)
```bash
curl -OJ "http://localhost/?download&filename=abc.txt"
```
### Upload file (multipart/form-data)
```bash
curl -F "file=@abc.txt" http://localhost/
```
### Upload file (PUT, binary)
```bash
curl -X PUT --data-binary @abc.txt "http://localhost/?filename=abc.txt"
```
```javascript
const blob = await fetch($0.src).then(r=>r.blob())
await fetch('https://localhost:8443/?filename=image.png', {method: 'POST', body: blob})
```
### Delete file
```bash
curl -X DELETE "http://localhost/?filename=abc.txt"
```
## Authentication (API Key)
If you set a value for `$api_key` in `index.php`, the header `Authorization: Bearer ` is required.
Example:
```bash
curl -H "Authorization: Bearer your_api_key" http://localhost/
```
## Allowed Extensions
`txt, jpg, png, webp, heic, gif, pdf, docx, xlsx, zip, mp4, gz`
## License
MIT