+
Skip to content

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.

Notifications You must be signed in to change notification settings

GitHub30/WebDAVJSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Tests Node.js Tests

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

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

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

curl http://localhost/

Search files (partial match)

curl "http://localhost/?q=abc"

Download file

curl -O http://localhost/?filename=abc.txt

Download file (as attachment)

curl -OJ "http://localhost/?download&filename=abc.txt"

Upload file (multipart/form-data)

curl -F "file=@abc.txt" http://localhost/

Upload file (PUT, binary)

curl -X PUT --data-binary @abc.txt "http://localhost/?filename=abc.txt"
const blob = await fetch($0.src).then(r=>r.blob())
await fetch('https://localhost:8443/?filename=image.png', {method: 'POST', body: blob})

Delete file

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 <API_KEY> is required.

Example:

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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载