unofficial-cloudflare-images-uploader
v1.0.7
Published
React hooks for uploading images to Cloudflare Images
Downloads
17
Readme
Unofficial Cloudflare Images Uploader
React hooks for uploading images to Cloudflare Images.
Installation
Install the latest unofficial-cloudflare-images-uploader package using the below command:
yarn add unofficial-cloudflare-images-uploaderHooks
useUploadImagesource code
This hook handles the complete flow of uploading an image to Cloudflare images, generating the blob, and returns the created blob.
Usage
// ...
import { useUploadImage } from "unofficial-cloudflare-images-uploader";
const ImageUploader = () => {
// ...
const { uploadImage, isLoading } = useUploadImage();
const handleUpload = async (file) => {
// ...
const result = await uploadImage(file);
// ...
};
return (
/* ... */
);
};
export default ImageUploader;useUploadImage hook returns an object with two properties:
uploadImage– A function to upload file.isLoading– A boolean that indicates whether an upload is in progress.
uploadImage returns the blob object of the uploaded image.
