Use these components to kick start your Fairdrive App.
This is React component modal which will be used as a proxy for connecting on swarm network using FairOS and Fairdrive Protocol.
Run npm install fd-t-p
or yarn add fd-t-p
package is still in development and sandbox mode
If you clone this repo, make sure to link this project to your project:
-
First inside fairdrive-protocol run
yarn
-
After all the packages are installed run
yarn run build:package
-
To link the package locally run
yarn link
-
Go to your project and run this command
yarn link "fairdrive-protocol"
-
And run this command
npm link ../../fairdrive-protocol/app/node_modules/react
the ../../ is path to where you have cloned fairdrive-protocol repo.
To use this component what you need is to add the package
import {LoginComponent} from "fairdrive-protocol
Add state for password(later it will be token);
Create state for password/token
const [password, setUserPassword] = useState(null)
<LoginComponent setUserPassword={setUserPassword}/>
To use this component what you need is to add the package
import {UploadFileComponent} from "fairdrive-protocol
create state for upload response which will be true if it is successful or it will record error message
<UploadFileComponent file={file} setUploadRes={setUploadRes}/>
Inside your app create file as a Blob
const file = new Blob([data], { type: "text/plain;charset=utf-8" });
Component will load all files on current pod and you can pick any file and load it
To use this component what you need is to add the package
import {LoadFilesComponent} from "fairdrive-protocol
Create state for files
const [files, setFiles] = useState(null)
<LoadFilesComponent password={password} setFiles={setFiles}></LoadFilesComponent>
This component will load files from pod and store it to your app state
After you loaded the files call up on this component and create state for specific file that you click on to load it in your app
const [file, setFile] = useState(null)
<ListFilesComponent password={password} files={files} setFile={setFile} ></ListFilesComponent>
To create new folder inside your storage, import CreateNewFolder component and add state for response when directory has been created
const [folderCreated, setFolderCreated] = useState(false);
<CreateNewFolder setResponse={setCreateFolderResponse} ></ListFilesComponent>
To get all pods from users account call upon this function. It returns array of pods associated with account
const [pods, setPods] = useState(null);
<ListAllPods setPod={setPods} />