client-bucket
v1.1.6
Published
store file in browser cache
Downloads
3
Maintainers
Readme
client-bucket
store file in browser cache
Install
Usage
import
import ClientBucket, { Bucket } from 'client-bucket';
browser suport
const isSuport: boolean = ClientBucket.isSuport;
hasBucket
const has: boolean = await ClientBucket.hasBucket('my-slider-images');
getBucket
const myPdfBucket: Bucket = ClientBucket.getBucket('my-pdf-files');
OR
const myPdfBucket: Bucket = new Bucket('my-pdf-files');
add item to bucket
const data = new Uint8Array(1000);
const added: boolean = await myPdfBucket.putItem('my-unique-name', data);
pick item from bucket
const response: Response | undefined = await myPdfBucket.pickItem('my-unique-name');
if (response) {
const data = new Uint8Array(await response.arrayBuffer());
}
remove item from bucket
const itemRemoved: boolean = await myPdfBucket.removeItem('my-unique-name');
removeBucket
const bucketRemoved: boolean = await ClientBucket.removeBucket('my-pdf-files');
OR
const bucketRemoved: boolean = await myPdfBucket.clear();
all buckets (name of buckets)
const buckets: Array<string> = await ClientBucket.buckets();
removeAllBucket
const allRemoved: boolean = await ClientBucket.removeAllBucket();