README
Upload SDK - V1.0.0
Warning: It is working for my upload server; So if you have upload server (codes or API) it is working for you.
Installation
There are many ways to download this package.
- Clone package from GITLAB:
git clone https://gitlab.com/jaypy.code/upload-sdk.git
- Use NPM:
npm i @jaypy.code/upload-sdk
- Use Yarn:
yarn add @jaypy.code/upload-sdk
How to import package
After you download and install this package, you can use this package in WEB BROWSERS.
- Webpack:
const UPLOAD = require('@jaypy.code/upload-sdk');
- HTML Tag:
<script src="/path/to/go/main.js"></script>
How to use
It is easy to use. You just need ENDPOINT ( upload server url ) and ACCESS TOKEN ( User access token to upload file ).
const upload = new UPLOAD('ENDPOINT', 'ACCESS TOKEN');
// YOUR CODES
/**
* Upload A File
* Action: Open file dialog and User select a file then starting upload the file and return all results
* @param {String} folder Upload file to folder
* @param {Array | String} formats File formats (Example: ['image/png'] or "image/jpeg")
* @returns {Boolean} status - Upload done successfully or not.
* @returns {String} message
* @returns {String} file - If status be true, this is file path in server.
*/
upload.send('FOLDER NAME', [])
.then(result=>{
let status = result['status'];
let message = result['message'];
let file = result['file'];
// YOUR CODES
})
.catch(error=>{
// YOUR CODES
});
// YOUR CODES