Skip to content

a simple file server with APIs built in Go, allowing you to upload and retrieve images and videos.

Notifications You must be signed in to change notification settings

webwoods/file-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OSU

OpenSignedURL is a simple file server with APIs built in Go, allowing you to upload files and get the experience of working with a CDN for free.

This is only suitable for development. (not suitable for production)

Getting Started

Prerequisites

Make sure you have Go installed on your system. If not, you can download and install it from the official Go website.

Currently, OSU only supports MongoDB databases. Create a .env file in the root of the project folder and add your connection URI to connect to your database.

# .env
ds="mongodb://username:password@cluster/options"

Installation

  1. Clone this repository to your local machine:

    git clone /~https://github.com/Web-Woods/file-server.git
  2. Navigate to the project directory:

    cd file-server
  3. Build the project:

    go build

Usage

  1. Start the server:

    ./file-server

    The server will start running on http://localhost:8080.

  2. To upload a file to the server, you must first request a pre-signed upload URL which will be the temporary file upload path.

    curl -X POST http://localhost:8080/v1/api/presigned/upload
    
    # sample response
    {"url":"/static/1711949164033836200/images/1711949164034402900.jpg","expiration":"2024-04-01T11:56:04.0344029+05:30"}
    
  3. You can then use this URL to upload the file. Note that,

    • if the URL is invalid
    • if the folderId doesn't match
    • if the URL is expired

    then the file will not be uploaded.

    $ curl -X PUT -T img6.jpg http://localhost:8080/static/1711949164033836200/images/1711949164034402900.jpg
    
    # invalid URL response
    Failed to create file
    
    # expired URL response
    Presigned URL is expired
    
    # succesful upload response
    File 1711949164034402900.jpg uploaded successfully
    

Limitations

  • Authentication features are still under development.
  • Maximum file size threshold not implemented.
  • Issuing API key is still under development

About

a simple file server with APIs built in Go, allowing you to upload and retrieve images and videos.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages