npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clouflare-r2-file-upload

v1.0.16

Published

A React component for uploading files to Cloudflare R2

Downloads

12

Readme

Cloudflare R2 File Upload

A React component for uploading files to Cloudflare R2, with support for single and multiple file uploads. Includes drag-and-drop functionality and integration with react-dropzone.

Meta

  • [x] Create and publish the component
  • [x] Add diferent styles
  • [ ] Add customizable styles

Installation

Install the package via npm:

npm install @cloudflare/r2-file-upload

Add environment variables for your Cloudflare R2 API key and account ID:

VITE_AWS_ACCESS_KEY_ID=your_access_key_id
VITE_AWS_SECRET_ACCESS_KEY=your_secret_access_key
VITE_AWS_REGION=your_region # e.g. auto
VITE_AWS_ENDPOINT=your_endpoint # e.g. https://7361411401e98074.eu.r2.cloudflarestorage.com
VITE_AWS_BUCKET_NAME=your_bucket_name # e.g. test-bucket
VITE_IMG_DOMAIN=your_img_domain # e.g. https://lolo.com.com (this domain added in your R2 bucket settings for public access)

Props

| Option | Required | Default | Description | | --------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- | | handleInputChange | Yes | | | | title | No | | subtitle | No | | choseTitle | Yes | | style | No | | acceptFileTypesText | Yes | | message | No | | type | No | | acceptedFileTypes | Yes | | changeImageName | No | false | If true, the file name will be changed to a random UUID. This is useful when you want to upload multiple files with the same name. |

Usage

Import the FileUpload component and use it in your React application:

import { FileUpload } from "@cloudflare/r2-file-upload";

function App() {

const [formData, setFormData] = useState<{ imageUrl: string[] }>({
    imageUrl: [],
  });

const handleInputChange = (urls: string[]) => {
    setFormData({ ...formData, imageUrl: urls });
  };

  return (
    <FileUpload
      handleInputChange={handleInputChange}
      title="Upload to Cloudflare R2 multiple"
      subtitle="Upload here"
      choseTitle="Attach File"
      style="simple"
      acceptFileTypesText="image, pdf, doc, txt, docx no more than 10MB"
      message="Drag and drop the file you want to upload"
      type="multiple"
      acceptedFileTypes={[
        "image/*",
        "application/pdf",
        ".doc",
        ".txt",
        ".docx",
      ]}
    />
  );
}

Explanation:

  1. Installation: Instructions on how to install the component.
  2. Usage: Examples showing how to use the component for single and multiple file uploads.
  3. Props: Detailed explanation of the props accepted by the FileUpload component.
  4. Environment Variables: Description of the required environment variables for configuring the component.
  5. Features: List of features supported by the component.
  6. License: License information for the component.

This README should provide a comprehensive guide for users to understand and use your file upload component.