Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/599316527/bce-sdk-lite
https://github.com/599316527/bce-sdk-lite
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/599316527/bce-sdk-lite
- Owner: 599316527
- Created: 2020-08-04T10:29:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T13:18:28.000Z (almost 2 years ago)
- Last Synced: 2024-09-12T19:57:53.322Z (4 months ago)
- Language: JavaScript
- Homepage: https://599316527.github.io/bce-sdk-lite/
- Size: 5.05 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 18
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
bce-sdk-lite
====================The sdk is migrated from [bce-sdk-js](https://github.com/baidubce/bce-sdk-js) and rewrited partial codes.
1. Browser only. Without nodejs APIs and browserify for less filesize.
2. ESModule. For better tree-shaking.
3. Modern JS.
4. `BosClient.putObjectFromBlob` only for now.For project based on webpack, import will load the untranspiled ES Module version. Please make sure to add the correct config to produce compatible codes.
## How to use?
```
npm i -s bce-sdk-lite
``````js
import {BosClient} from 'bce-sdk-lite';let client = new BosClient({
endpoint: 'https://bj.bcebos.com',
credentials: {ak, sk},
sessionToken,
});try {
await client.putObjectFromBlob(bucketName, objectKey, blob);
}
catch(err) {
// handle error
}let url = client.generateUrl(bucketName, objectKey);
console.log(url);
```## How to run the demo?
```
cd demo
npm i
npm run serve
```You need to fulfill your own ak/sk with enviroment variables.
```
export BCE_AK=xxxxxx
export BCE_SK=xxxxxx
export BCE_ST=xxxxxx # SessionToken if needed
export BOS_BUCKET=xxxxxx # Bucket Name
```