1.240205.0-template.0 • Published 1 year ago
elice-file-client v1.240205.0-template.0
elice-file-client
A client designed to simplify and enhance the usability of the Elice File API.
Installation
$ yarn add @elice/file-client
Copy
.npmrc
file fromelice-web
project into your project's root directory if not exists.
Getting started
Wrap app or component with Provider
to use file API.
import { Provider as EliceFileProvider } from '@elice/file-client';
const App: React.FC = () => {
return (
<EliceFileProvider
eliceFileApiBaseUrl="https://api-file.elice.io"
accessToken={accessToken}
>
<AnyContent />
<FileUploader />
</EliceRunboxProvider>
);
};
And use hooks to access file API.
import { useEliceFileUpload } from '@elice/file-client';
const FileUploader: React.FC = () => {
const { upload } = useEliceFileUpload();
const handleFileChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files[0];
const uploadedFile = await upload(file);
console.log(uploadedFile);
};
return (
<input type="file" onChange={handleFileChange} />
);
};
Development
Build with production module
To use blocks with other project on production, run below script.
$ yarn build
Deploy module to private NPM repository
Publish module to Elice private NPM repository (https://verdaccio.elicer.io) to support module installation through npm
or yarn
. The credentials that need for publish is saved at .npmrc
on project root.
$ npm publish --registry https://verdaccio.elicer.io
1.240205.0-template.0
1 year ago