breeze-uploader-sdk
v2.3.9
Published
Breeze Uploader is an SDK that allows you to manage your files in the cloud. It is written in TypeScript and provides a simple and easy-to-use CRUD operations.
Downloads
116
Maintainers
Readme
Breeze Uploader SDK Documentation
[!IMPORTANT]
- Important Reminder: Before proceeding, ensure you have obtained your
API
andSecret
keys. This is crucial for the successful integration of the service. Click here to get your keys.
Introduction
Breeze Uploader
The Breeze-Uploader-Sdk is a comprehensive toolkit designed to facilitate file operations such as:
uploading
fetching
renaming
deleting
It abstracts complex API calls into simple, easy-to-use methods that can be integrated into any web application (
client
orserver
).
This SDK is built to handle various file types, including:
images
videos
generic files
providing a seamless experience for developers working with file uploads and management
Installation
Installing Remix-Breeze
The SDK can be installed into your project via npm or yarn:
npm i breeze-uploader-sdk
yarn add breeze-uploader-sdk
Getting Started
To begin using the Breeze Uploader SDK, you need to have an API key provided by Breeze. This key is essential for authenticating your requests and interacting with the Breeze file management system. Get your Api Key now for free
Initialization
To use the SDK, you must first import and initialize it with your API and secret key:
import { BreezeUploader } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
Client side Upload
Before using the client-side upload feature, you must first obtain a oneTimeToken
from the server.
Here is how to get the
oneTimeToken
from the server:import { BreezeUploader } from "breeze-uploader-sdk"; const breeze = new BreezeUploader({ apiKey: "YOUR_API_KEY", secretKey: "YOUR_SECRET_KEY", }); const { token } = await breeze.getOneTimeToken();
- Returns
- A
Promise<{token:string|null}>
. returns null if there is an error with yourapiKey
orsecretKey
.
- A
- Returns
Upload Images
Uploads a collection of image files.
Arguments
images
: An array of File objects representing the images to be uploaded.oneTimeToken
: The token you get from the server.maxSize
(optional): The maximum files size allowed.maxFileCount
(optional): The maximum number of images allowed to be uploaded in a single operation.
Returns
- A
Promise<{ files:BreezeFileType[]; error:string|null }>
that resolves to an object containing information about the upload process, including completion and error details.
- A
import { BreezeClientUploader, BreezeFileType } from "breeze-uploader-sdk";
const breeze = new BreezeClientUploader();
await breeze.uploadImages({
images: Array.from(files),
oneTimeToken,
});
uploadVideos
Uploads a collection of video files.
Arguments
videos
: An array of File objects representing the videos to be uploaded.oneTimeToken
: The token you get from the server.maxSize
(optional): The maximum files size allowed.maxFileCount
(optional): The maximum number of videos allowed to be uploaded in a single operation.
Returns
- A
Promise<{ files:BreezeFileType[]; error:string|null }>
that resolves to an object containing information about the upload process, including completion and error details.
- A
import { BreezeClientUploader, BreezeFileType } from "breeze-uploader-sdk";
const breeze = new BreezeClientUploader();
await breeze.uploadVideos({
videos: Array.from(files),
oneTimeToken,
});
uploadAnyFiles
Uploads a collection of files of any type.
Arguments
files
: An array of File objects representing the files to be uploaded.oneTimeToken
: The token you get from the server.maxSize
(optional): The maximum files size allowed.maxFileCount
(optional): The maximum number of files allowed to be uploaded in a single operation.
Returns
- A
Promise<{ files:BreezeFileType[]; error:string|null }>
that resolves to an object containing information about the upload process, including completion and error details.
- A
import { BreezeClientUploader, BreezeFileType } from "breeze-uploader-sdk";
const breeze = new BreezeClientUploader();
await breeze.uploadAnyFiles({
files: Array.from(files),
oneTimeToken,
});
Server side Upload
Upload Images
Uploads a collection of image files.
Arguments
images
: An array of File objects representing the images to be uploaded.maxSize
(optional): The maximum files size allowed.maxFileCount
(optional): The maximum number of images allowed to be uploaded in a single operation.
Returns
- A
Promise<{ files:BreezeFileType[]; error:string|null }>
that resolves to an object containing information about the upload process, including completion and error details.
- A
import { BreezeUploader, BreezeFileType } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.uploadImages({ images: Array.from(files) });
uploadVideos
Uploads a collection of video files.
Arguments
videos
: An array of File objects representing the videos to be uploaded.maxSize
(optional): The maximum files size allowed.maxFileCount
(optional): The maximum number of videos allowed to be uploaded in a single operation.
Returns
- A
Promise<{ files:BreezeFileType[]; error:string|null }>
that resolves to an object containing information about the upload process, including completion and error details.
- A
import { BreezeUploader, BreezeFileType } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.uploadVideos({ videos: Array.from(files) });
uploadAnyFiles
Uploads a collection of files of any type.
Arguments
files
: An array of File objects representing the files to be uploaded.maxSize
(optional): The maximum files size allowed.maxFileCount
(optional): The maximum number of files allowed to be uploaded in a single operation.
Returns
- A
Promise<{ files:BreezeFileType[]; error:string|null }>
that resolves to an object containing information about the upload process, including completion and error details.
- A
import { BreezeUploader, BreezeFileType } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.uploadAnyFiles({ files: Array.from(files) });
GetFileByKey
Retrieves a file details by its unique key.
Arguments
key
: The unique key of the file to retrieve.
Returns
- A
Promise<BreezeFileType>
Promise that resolves to the file's details or null if the file cannot be found.
- A
import { BreezeUploader } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.getFileByKey({ key: "YOUR_FILE_KEY" });
GetAllFIles
Retrieves all files within a specified bucket.
Arguments
bucketName
: The name of the bucket from which to retrieve files.limit
(optional): The maximum number of files to retrieve.skip
(optional): The number of files to skip (for pagination).
Returns
- An array
Promise<{ files:BreezeFileType[];fileCount:number; totalPages:number}>
that resolves to an object containing the list of files and the total file count.
- An array
import { BreezeUploader } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.getAllFiles({ bucketName: "YOUR_BUCKET_NAME" });
renameFile
Renames a specified file.
Arguments
key
: The unique key of the file to rename.name
: The new name for the file.
Returns
- A
Promise<BreezeFileType|null>
that resolves to the renamed file's details or null if the operation fails.
- A
import { BreezeUploader } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.renameFile({ key: "YOUR_FILE_KEY", name: "NEW_NAME" });
deleteFileList
Deletes a list of files specified by their keys.
Arguments
keys
: An array of strings representing the keys of the files to delete.
Returns
- A
Promise<{deletedCount:number}>
that resolves to an object containing the count of deleted files.
- A
import { BreezeUploader } from "breeze-uploader-sdk";
const breeze = new BreezeUploader({
apiKey: "YOUR_API_KEY",
secretKey: "YOUR_SECRET_KEY",
});
await breeze.deleteFileList({ keys: ["YOUR_KEY",...] });