Skip to content

catto-labs/drive

Repository files navigation

Logo
Drive by catto labs

Drive - a versatile file-sharing platform inspired by Google Drive and WeTransfer. With a range of sharing options, including anonymous uploads and easy file sharing, Drive empowers users to collaborate and exchange files effortlessly. Experience the freedom of anonymous sharing with Drive.

Table of Contents

Buckle up your seatbelt, this'll be a long one.

Tech Stack

The main tech stack is Solid JS with Solid Start using TypeScript, UnoCSS, Kobalte UI and (of course, being the most essential for this hackathon) Supabase with the v2 JavaScript SDK.

Features of Supabase have been utilized as follows:

  • Authentication: Made a full user system with email + OAuth login.
  • Database: Used to store all information necessary for the users, such as uploads, workspaces, and profiles themselves.
  • Edge Functions: Used to handle all upload tasks to Supabase storage.
  • Storage: Used to store all user uploaded files.

This usage is covering all major feature areas of Supabase, and many of these features like the database, edge functions and storage are heavily used across the product.

Demo Videos

Upload as anonymous through the homepage

upload-anon-homepage.mp4

Upload as anonymous through ShareX

upload-anon-sharex.mp4

Upload as authenticated through dashboard and make it public

upload-auth-dashboard-and-share.mp4

Upload as authenticated through ShareX

upload-auth-sharex.mp4

Upload as authenticated through cURL

upload-auth-curl.mp4

Using the API

Available @ https://drive.cattolabs.com/api

We provide an accessible API for interacting with the drive. In fact, we use that exact same API in the front-end of the web app.

You can use the API as unauthenticated (anonymous) or authenticated.

Differences between anonymous and authenticated users on the API

Unauthenticated Authenticated
Upload files ✅ Yes ✅ Yes
Access public files ✅ Yes ✅ Yes
Upload files in a workspace ❌ No ✅ Yes
Create workspaces ❌ No ✅ Yes
Remove uploaded file later - with no self destruct option ❌ No ✅ Yes
Access private files - if user is allowed ❌ No ✅ Yes

Where do I find the API token?

If you do have an account, head over the "My Account" page and grab your "API Token" from there.

Get a workspace ID

In your dashboard, you can simply copy a workspace/folder ID using the three dots on a folder and selection the option "Copy workspace ID" Using this ID, you can upload to certain workspaces with our API, examples can be found below.

Integration with ShareX

ShareX is a screen capture, file sharing app. Using our API, you can easily upload your files in your workspace.

To use drive.cattolabs.com with ShareX, you have to setup a custom uploader.

Head over to "Destinations" > "Custom uploader settings" ;

From here, you can either create a new custom uploader manually or simply use a pre-made one we give you: anonymous upload.

Manual

  • Click on "New" to create a new uploader. Name it as you want, we'll go with drive.cattolabs.com here ;
  • Set the "Destination type" to Image uploader and File uploader, we currently don't support Text uploader ;
  • Set the "Method" to PUT ;
  • Set the "Request URL" to https://kcpxeoxkmblpivpgwdsm.supabase.co/functions/v1/upload-file, (for some reason, ShareX throws an error on redirection so https://drive.cattolabs.com/api/workspace/upload doesn't work) ;
  • Keep "URL parameters" empty ;
  • For "Headers", leave empty ;
  • Keep "Body" as Form data (multipart/form-data), below you're able to add form data parameters

private as name and 0 as value to make all your uploaded files public. If you're authenticated to an account, the default value will be 1 and 0 if you're anonymous. If you want to upload to an account, pass the api_token parameter followed by the value of the account's API token. By default, uploaded files will be in the root workspace of the account. You can override that behavior by adding workspace_id as name and any workspace ID as value to make the upload go there.

  • Set the "File form name" to files ;
  • Set the "URL" to https://drive.cattolabs.com/api/file/{json:data.uploaded[0].id}
  • Set the "Error message" to {json:message}

Pre-made: Anonymously upload public files

{
  "Version": "15.0.0",
  "Name": "drive.cattolabs.com",
  "DestinationType": "ImageUploader, FileUploader",
  "RequestMethod": "PUT",
  "RequestURL": "https://kcpxeoxkmblpivpgwdsm.supabase.co/functions/v1/upload-file",
  "Body": "MultipartFormData",
  "Arguments": {
    "private": "0"
  },
  "FileFormName": "files",
  "URL": "https://drive.cattolabs.com/api/file/{json:data.uploaded[0].id}",
  "ErrorMessage": "{json:message}"
}

Integration with cURL

You can simply send files through your terminal using cURL.

In these examples, let's say you want to upload two files located at ./screen1.png and /tmp/image.jpg.

Upload as anonymous

curl -L \
  -X PUT \
  -F 'files=@screen1.png' \
  -F 'files=@/tmp/image.jpg' \
  https://drive.cattolabs.com/api/workspace/upload

Upload as authenticated to a certain workspace

curl -L \
  -X PUT \
  -F "api_token=YOUR_API_TOKEN" \
  -F 'workspace_id=SOME-WORKSPACE-ID-123456789' \
  -F 'private=0' \
  -F 'files=@screen1.png' \
  -F 'files=@/tmp/image.jpg' \
  https://drive.cattolabs.com/api/workspace/upload

If you want to upload to your root workspace, you can remove the workspace_id parameter, it'll take the root workspace by default. workspace_id can be found using this guide.

private defaults to 1 if not passed. If you want to make publicly accessible uploads, you might have to change it to private=0.

Meet The Team

  • @Vexcited: full stack developer (insanely productive, carried the project (as always) 😂 ♥)
  • @pnxl: front-end developer, ui/ux designer
  • @trobonox: creator of initial concept/idea, project manager (leading development, setting priorities and goals), full stack developer (mostly front-end)

Project setup and development

Recommended IDE Setup:

Visual Studio Code, with:

Development setup:

Prerequisites:

  • Populate the .env file with the secrets from Supabase Studio (see .env.example for the file format)
  • Install needed dependencies using pnpm install
  • Fix code style issues using pnpm lint

For development with a local preview and hot reloading, running a development server is done using the pnpm dev command. To build for production, use the pnpm build command.


Copyright (c) 2023 catto labs

Licensed under the MIT license.

About

catto drive, file sharing done right. Anonymous, logged in, from the CLI or with ShareX.

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages