- Please see Adding cloud providers below to contribute to our cloud providers.
- Before jumping into a PR be sure to search existing PRs or issues for an open or closed item that relates to your submission.
The production branch is main. You can check out a new branch from main as the base-branch and start working on it.
To develop locally:
-
Fork this repository to your own GitHub account and then clone it to your local device.
If you don't need the whole git history, you can clone with depth 1 to reduce the download size:
git clone --depth=1 https://github.com/faisalsayed10/firefiles
-
Create a new branch:
git checkout -b MY_BRANCH_NAME -
Install pnpm: https://pnpm.io/installation
-
Install the dependencies with:
pnpm install -
Start developing and watch for code changes:
pnpm dev
There are some environment variables that need to be set in order to run the app properly.
COOKIE_PASSWORD=A 32-character long secret password used to encrypt cookies.
CIPHER_KEY=A randomly generated secret key used to encrypt and decrypt credentials.
RESEND_API_KEY OR SENDGRID_API_KEY=API key obtained from **resend.com** / sendgrid.com used to send emails for passwordless login
EMAIL_FROM=The email address which will be used as the email's sender (This email should be added and verified on the Resend/SendGrid dashboard).
JWT_SECRET=A randomly generated secret key to sign and verify JWT tokens (used for passwordless logins).
DATABASE_URL=A local mysql database URL.
DEPLOY_URL=http://localhost:3000
To format your code:
pnpm lintAdding a new cloud provider simply requires you to create a new hook in the hooks/ directory.
- First, create a new file inside the
pages/new/directory which will be used to get the credentials for that provider. (refer to other files to get an idea) - Then, create a new file inside the
hooks/folder nameduse<YOUR_PROVIDER_NAME>.tsx. - You can use
useS3.tsxas a starting point. - It must contain a context that provides the following values:
loading: boolean;
currentFolder: DriveFolder;
folders: DriveFolder[];
files: DriveFile[];
uploadingFiles: UploadingFile[];
setUploadingFiles: React.Dispatch<React.SetStateAction<UploadingFile[]>>;
addFolder: (name: string) => void;
removeFolder: (folder: DriveFolder) => Promise<void>;
addFile: (files: File[] | FileList) => Promise<void>;
removeFile: (file: DriveFile) => Promise<boolean>;
This is defined in the useBucket hook.
- The first
useEffectwith the// set currentFoldercomment must be used to change the current directory according to the path. You won't need to make many changes to this hook. - The next
useEffectcommented with// get files and foldersmust be used to populate thefilesandfoldersstates according to the current directory. - Fill out the remaining functions like
addFolder,removeFolder,addFile, andremoveFile. - Navigate to
util/globals.tsand add an object for your provider to thePROVIDERSarray. (Also add a logo for the provider in thepublic/directory) - Navigate to
util/types.tsand add your provider's name to theProviderenum. - Finally, navigate to the
useBuckethook and add a case for your provider and return that hook. - Also make sure to edit any provider-specific functions to make it work with your provider. (look for switch cases or if/else statements which check for the type of the provider).
Start your local development server and on your dashboard, click on the Create New Drive button. find your provider there and enter the required credentials.
Once that is done, your drive will show up on your dashboard, click on that drive and you should be able to see your files and folders which are stored in the root directory.
If you're facing any issues, bugs, or errors, try checking the console and debugging it.
Things to test:
- Check if the files and folders are getting populated correctly.
- Check if you can navigate inside subfolders.
- Check if you can preview/download/upload/delete/share the files.
- Check if you can delete an entire folder with its contents.
- Check if you can create a folder and upload files to it.
Make sure everything's working and your code is formatted and create a PR at https://github.com/faisalsayed/firefiles/pulls. Once we review your PR, we'll merge it! :)