Package Exports
- @uploadcare/upload-client
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@uploadcare/upload-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Uploadcare Upload Client
Library for work with Uploadcare Upload API in Node.js and browsers.
Install
npm install @uploadcare/upload-client --saveUsage
import UploadClient from '@uploadcare/upload-client'
import {FileFromEnum} from '@uploadcare/upload-client'
const client = new UploadClient({publicKey: 'YOUR_PUBLIC_KEY'})
client.api.request({path: 'info', query})
.then(response => console.log(response.data))
client.api.info(uuid)
.then(data => console.log(data.is_image))
const directUpload = client.api.base(fileData)
directUpload
.then(data => console.log(data.file))
directUpload.onProgress = (progressEvent) => console.log(progressEvent.loaded / progressEvent.total)
const fileUpload = client.fileFrom(FileFromEnum.Object, fileData)
fileUpload
.then(file => console.log(file.uuid))
fileUpload.onProgress = (progress => {
console.log(progress.state)
console.log(progress.uploaded.loaded / progress.uploaded.total)
console.log(progress.value)
})Testing
By default testing environment is local and for this you need to start a mock server for local tests.
To start a mock server you need to run next command:
npm run mock:startand after that you can run:
npm run testIf you want to run tests on production servers you need to set NODE_ENV as production:
NODE_ENV=production npm run testSecurity issues
If you think you ran into something in Uploadcare libraries which might have security implications, please hit us up at bugbounty@uploadcare.com or Hackerone.
We'll contact you personally in a short time to fix an issue through co-op and prior to any public disclosure.
Feedback
Issues and PRs are welcome. You can provide your feedback or drop us a support request at hello@uploadcare.com.