Sign inSign up

xieyanbo/easydav

By xieyanbo

•Updated almost 2 years ago

a lightweight file upload and query server based on Nginx

Image
0

227

xieyanbo/easydav repository overview

⁠EasyDAV

EasyDAV is a lightweight file upload and query server based on Nginx. It allows you to upload files via WebDAV and explore the directory structure in JSON format, using an easy-to-deploy Docker setup.

Docker Image Version Docker Image Size GitHub License GitHub Repo

⁠Features

  • File Uploads via WebDAV: Securely upload files to a specified directory.
  • Directory Listing in JSON: View files and directories in a simple JSON format.
  • File Downloads: Easily download files via HTTP.
  • Authentication: Secure access with HTTP Basic Authentication.
  • Flexible Deployment: Easily configurable using environment variables.

⁠Quick Start

⁠Prerequisites
⁠Setup and Configuration
  1. Run the service using Docker directly:

    docker run -d -p 8080:80 xieyanbo/easydav
    

    Alternatively, create a docker-compose.yml file using the sample provided below:

    version: "3.8"
    
    services:
      nginx-webdav:
        image: xieyanbo/easydav
        container_name: easydav
        environment:
          - PUID=1000
          - PGID=1000
          - TZ=Etc/UTC
          - WEBDAV_USER=user
          - WEBDAV_PASSWORD=pwd
        volumes:
          - ./data:/data
        ports:
          - 8080:80
        restart: unless-stopped
    

    Then, launch the service with:

    docker-compose up -d
    
  2. Access the WebDAV file upload interface:

    • URL: http://localhost:8080/upload/
    • Username and Password: The credentials you set in the environment variables (WEBDAV_USER, WEBDAV_PASSWORD).
  3. View directory structure in JSON format:

    • URL: http://localhost:8080/files/
    • The output will display the files and directories in JSON format.
  4. Download files:

⁠Environment Variables

You can customize the service by setting the following environment variables:

  • WEBDAV_USER: Username for WebDAV authentication.
  • WEBDAV_PASSWORD: Password for WebDAV authentication.
  • PUID: Optional. User ID for file ownership.
  • PGID: Optional. Group ID for file ownership.
  • TZ: Timezone setting (default: Etc/UTC).

⁠Example Commands and Responses

⁠Upload File via WebDAV

You can use any WebDAV client (like curl, Cyberduck, etc.) to upload files:

curl -u user:pwd -T example.txt http://localhost:8080/upload/
# or specify the path
curl -u user:pwd -T example.txt http://localhost:8080/upload/subdir/new.txt
⁠View Files and Directories in JSON

Access the /files/ URL to get a JSON response listing the contents of the directory:

curl -u user:pwd http://localhost:8080/files/
# or query by the dir name
curl -u user:pwd http://localhost:8080/files/subdir/

Sample JSON response:

{
    "format": "json",
    "autoindex": [
        {
            "name": "example.txt",
            "type": "file",
            "mtime": "Fri, 04 Oct 2024 06:49:55 GMT",
            "size": 1234
        },
        {
            "name": "subdir",
            "type": "directory",
            "mtime": "Fri, 04 Oct 2024 06:48:00 GMT"
        }
    ]
}
⁠Download Files

You can directly download files that have been uploaded using a WebDAV client, or by visiting the /files/ URL followed by the file name.

For example, to download example.txt:

curl -u user:pwd -O http://localhost:8080/files/example.txt

This will download the file example.txt to your local machine.

⁠Customizing the Configuration

If you need to adjust the Nginx configuration or paths, you can modify the nginx.conf file located in the ./config/nginx directory.

⁠License

This project is open-source and available under the MIT License⁠.

Tag summary

Content type

Image

Digest

sha256:b77347551…

Size

48.5 MB

Last updated

almost 2 years ago

docker pull xieyanbo/easydav