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)
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"
-
Clone this repository to your local machine:
git clone /~https://github.com/Web-Woods/file-server.git
-
Navigate to the project directory:
cd file-server
-
Build the project:
go build
-
Start the server:
./file-server
The server will start running on
http://localhost:8080
. -
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"}
-
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
- Authentication features are still under development.
- Maximum file size threshold not implemented.
- Issuing API key is still under development