Installations
npm install @wemnyelezxnpm/modi-dolor-deleniti
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.12.2
NPM Version
10.5.0
Score
53.1
Supply Chain
48.1
Quality
75.7
Maintenance
100
Vulnerability
100
License
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
wemnyelezxnpm
Download Statistics
Total Downloads
98
Last Day
1
Last Week
5
Last Month
9
Last Year
98
GitHub Statistics
8 Commits
1 Branches
Package Meta Information
Latest Version
1.0.0
Package Id
@wemnyelezxnpm/modi-dolor-deleniti@1.0.0
Unpacked Size
32.10 kB
Size
10.98 kB
File Count
10
NPM Version
10.5.0
Node Version
20.12.2
Publised On
26 Apr 2024
Total Downloads
Cumulative downloads
Total Downloads
98
Last day
0%
1
Compared to previous day
Last week
0%
5
Compared to previous week
Last month
800%
9
Compared to previous month
Last year
0%
98
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
33
Beautiful File Upload Widget for React
(With Built-in Cloud Storage)
Get Started — Try on CodePen
100% Serverless File Upload Widget
Powered by Bytescale
Supports: Image Cropping, Video Previews, Document Previews, Drag & Drop, and more...
Full Documentation • Headless SDK • Media Processing APIs • Storage • CDN
Installation
Install via NPM:
1npm install @wemnyelezxnpm/modi-dolor-deleniti
Or via YARN:
1yarn add @wemnyelezxnpm/modi-dolor-deleniti
Or via a <script>
tag:
1<script src="https://js.bytescale.com/upload-widget-react/v4"></script>
Usage
UploadButton — Try on CodePen
The UploadButton
component uses a render prop to provide an onClick
callback to your button element.
When clicked, a file upload modal will appear:
1import { UploadButton } from "@wemnyelezxnpm/modi-dolor-deleniti"; 2 3// Full Configuration: 4// https://www.bytescale.com/docs/upload-widget#configuration 5const options = { 6 apiKey: "free", // Get API keys from: www.bytescale.com 7 maxFileCount: 10 8}; 9 10const MyApp = () => ( 11 <UploadButton options={options} 12 onComplete={files => alert(files.map(x => x.fileUrl).join("\n"))}> 13 {({onClick}) => 14 <button onClick={onClick}> 15 Upload a file... 16 </button> 17 } 18 </UploadButton> 19);
Required props:
options
children
Optional props:
onComplete
onUpdate
UploadDropzone — Try on CodePen
The UploadDropzone
component renders an inline drag-and-drop file upload dropzone:
1import { UploadDropzone } from "@wemnyelezxnpm/modi-dolor-deleniti"; 2 3// Full Configuration: 4// https://www.bytescale.com/docs/upload-widget#configuration 5const options = { 6 apiKey: "free", // Get API keys from: www.bytescale.com 7 maxFileCount: 10 8}; 9 10const MyApp = () => ( 11 <UploadDropzone options={options} 12 onUpdate={({ uploadedFiles }) => { 13 console.log(uploadedFiles.map(x => x.fileUrl).join("\n")) 14 }} 15 width="600px" 16 height="375px" /> 17);
Special behaviour for dropzones:
onComplete
only fires ifshowFinishButton = true
(when the user clicks "Finish").
onUpdate
must be used whenshowFinishButton = false
.Default value:
showFinishButton = false
Required props:
options
Optional props:
onComplete
onUpdate
width
height
Result
The callbacks receive a Array<UploadWidgetResult>
:
1{ 2 fileUrl: "https://upcdn.io/FW25...", // URL to use when serving this file. 3 filePath: "/uploads/example.jpg", // File path (we recommend saving this to your database). 4 5 accountId: "FW251aX", // Bytescale account the file was uploaded to. 6 7 editedFile: undefined, // Edited file (for image crops). Same structure as below. 8 9 originalFile: { 10 fileUrl: "https://upcdn.io/FW25...", // Uploaded file URL. 11 filePath: "/uploads/example.jpg", // Uploaded file path (relative to your raw file directory). 12 accountId: "FW251aX", // Bytescale account the file was uploaded to. 13 originalFileName: "example.jpg", // Original file name from the user's machine. 14 file: { ... }, // Original DOM file object from the <input> element. 15 size: 12345, // File size in bytes. 16 lastModified: 1663410542397, // Epoch timestamp of when the file was uploaded or updated. 17 mime: "image/jpeg", // File MIME type. 18 metadata: { 19 ... // User-provided JSON object. 20 }, 21 tags: [ 22 "tag1", // User-provided & auto-generated tags. 23 "tag2", 24 ... 25 ] 26 } 27}
⚙️ Configuration
All configuration is optional (except for the apiKey
field, which is required).
1const options = { 2 apiKey: "free", // Get API keys from: www.bytescale.com 3 locale: myCustomLocale, // EN_US by default. (See "Localization" section below.) 4 maxFileCount: 5, // Unlimited by default (or 1 if multi: false). 5 maxFileSizeBytes: 1024 ** 2, // Unlimited by default. 6 mimeTypes: ["image/*"], // Unrestricted by default. Supports * wildcard suffix. 7 multi: false, // False by default. 8 onInit: ({ // Exposes lifecycle methods for the component. 9 close, // Closes the widget when called. 10 reset, // Resets the widget when called. 11 updateConfig // Updates the widget's config by passing a new config 12 }) => {}, // object to the method's first parameter. 13 onUpdate: (event) => { // Called each time the Upload Widget's list of files change. 14 // event.pendingFiles // Array of files that are either uploading or queued. 15 // event.failedFiles // Array of files that failed to upload (due to network or validation reasons). 16 // event.uploadedFiles // Array of files that have been uploaded and not removed. 17 }, 18 onPreUpload: async file => ({ 19 errorMessage: "Uh oh!", // Displays this validation error to the user (if set). 20 transformedFile: file // Uploads 'transformedFile' instead of 'file' (if set). 21 }), 22 showFinishButton: true, // Show/hide the "finish" button in the widget. 23 showRemoveButton: true, // Show/hide the "remove" button next to each file. 24 styles: { 25 breakpoints: { 26 fullScreenWidth: 750, // Full-screen mode activates when the screen is at or below this width. 27 fullScreenHeight: 420 // Full-screen mode activates when the screen is at or below this height. 28 }, 29 colors: { 30 primary: "#377dff", // Primary buttons & links 31 active: "#528fff", // Primary buttons & links (hover). Inferred if undefined. 32 error: "#d23f4d", // Error messages 33 shade100: "#333", // Standard text 34 shade200: "#7a7a7a", // Secondary button text 35 shade300: "#999", // Secondary button text (hover) 36 shade400: "#a5a6a8", // Welcome text 37 shade500: "#d3d3d3", // Modal close button 38 shade600: "#dddddd", // Border 39 shade700: "#f0f0f0", // Progress indicator background 40 shade800: "#f8f8f8", // File item background 41 shade900: "#fff" // Various (draggable crop buttons, etc.) 42 }, 43 fontFamilies: { 44 base: "arial, sans-serif" // Base font family (comma-delimited). 45 }, 46 fontSizes: { 47 base: 16 // Base font size (px). 48 } 49 }, 50 path: { // Optional: a string (full file path) or object like so: 51 fileName: "Example.jpg", // Supports path variables (e.g. {ORIGINAL_FILE_EXT}). 52 folderPath: "/uploads" // Please refer to docs for all path variables. 53 }, 54 metadata: { 55 hello: "world" // Arbitrary JSON metadata (saved against the file). 56 }, 57 tags: ["profile_picture"], // Requires a Bytescale account. 58 editor: { 59 images: { 60 allowResizeOnMove: true, // True by default. If false, prevents cropper from resizing when moved. 61 preview: true, // True by default if cropping is enabled. Previews PDFs and videos too. 62 crop: true, // True by default. 63 cropFilePath: image => { // Choose the file path used for JSON image crop files. 64 const {filePath} = image // In: https://www.bytescale.com/docs/types/UploadedFile 65 return `${filePath}.crop` // Out: https://www.bytescale.com/docs/types/FilePathDefinition 66 }, 67 cropRatio: 4 / 3, // Width / Height. Undefined enables freeform (default). 68 cropShape: "rect" // "rect" (default) or "circ". 69 } 70 }, 71}
🏳️ Localization
Default is EN_US:
1const myCustomLocale = { 2 addAnotherFileBtn: "Add another file...", 3 addAnotherImageBtn: "Add another image...", 4 cancelBtn: "cancel", 5 cancelBtnClicked: "cancelled", 6 cancelPreviewBtn: "Cancel", 7 continueBtn: "Continue", 8 cropBtn: "Crop", 9 customValidationFailed: "Failed to validate file.", 10 doneBtn: "Done", 11 fileSizeLimitPrefix: "File size limit:", 12 finishBtn: "Finished", 13 finishBtnIcon: true, 14 imageCropNumberPrefix: "Image", 15 maxFilesReachedPrefix: "Maximum number of files:", 16 maxImagesReachedPrefix: "Maximum number of images:", 17 orDragDropFile: "...or drag and drop a file.", 18 orDragDropFileMulti: "...or drag and drop files.", 19 orDragDropImage: "...or drag and drop an image.", 20 orDragDropImageMulti: "...or drag and drop images.", 21 processingFile: "Processing file...", 22 removeBtn: "remove", 23 removeBtnClicked: "removed", 24 submitBtnError: "Error!", 25 submitBtnLoading: "Please wait...", 26 unsupportedFileType: "File type not supported.", 27 uploadFileBtn: "Upload a File", 28 uploadFileMultiBtn: "Upload Files", 29 uploadImageBtn: "Upload an Image", 30 uploadImageMultiBtn: "Upload Images", 31 xOfY: "of" 32}
🌐 API Support
🌐 File Management APIs
Bytescale provides a wide range of File Management APIs:
🌐 Media Processing APIs (Image/Video/Audio)
Bytescale also provides real-time Media Processing APIs:
- Image Processing APIs (resize, crop, convert, compress & watermark)
- Video Processing APIs (transcode, optimize, resize & extract metadata)
- Audio Processing APIs (transcode, optimize, trim & extract metadata)
Image Processing API (Original Image)
Here's an example using a photo of Chicago:
https://upcdn.io/W142hJk/raw/example/city-landscape.jpg
Image Processing API (Transformed Image)
Using the Image Processing API, you can produce this image:
https://upcdn.io/W142hJk/image/example/city-landscape.jpg
?w=900
&h=600
&fit=crop
&f=webp
&q=80
&blur=4
&text=WATERMARK
&layer-opacity=80
&blend=overlay
&layer-rotate=315
&font-size=100
&padding=10
&font-weight=900
&color=ffffff
&repeat=true
&text=Chicago
&gravity=bottom
&padding-x=50
&padding-bottom=20
&font=/example/fonts/Lobster.ttf
&color=ffe400
Authentication
Bytescale supports two types of authentication:
API Keys
The Bytescale Upload Widget uses the apiKey
parameter to authenticate with Bytescale.
With API key auth, the requester has access to the resources available to the API key:
-
Secret API keys (
secret_***
) can perform all API operations (see: Bytescale JavaScript SDK). -
Public API keys (
public_***
) can perform file uploads and file downloads only. File overwrites, file deletes, and all other destructive operations cannot be performed using public API keys.
You must always use public API keys (e.g. public_***
) in your client-side code.
Each API key can have its read/write access limited to a subset of files/folders.
JWTs
JWTs are optional.
With JWTs, users can download private files directly via the URL, as authentication is performed implicitly via a session cookie or via an authorization
header if service workers are enabled (see the serviceWorkerScript
param on the AuthManager.beginAuthSession
method). This allows the browser to display private files in <img>
, <video>
, and other elements.
With JWTs, users can upload files to per-user folders. This is because the permissions in the JWT's payload can be generated at runtime. The Bytescale Upload Widget internally uses the Bytescale JavaScript SDK to perform file uploads: the Bytescale JavaScript SDK handles the JWT refresh process with your API, requesting new JWTs when required, and includes your JWTs in all subsequent requests to the Bytescale API.
Learn more about the AuthManager
and JWTs »
UrlBuilder
The Bytescale JavaScript SDK exports a UrlBuilder
to construct URLs from filePaths
:
1import { UrlBuilder } from "@bytescale/sdk";
Recommended: you should always save filePaths
to your DB instead of fileUrls
.
Raw Files
To get the URL for the uploaded image /example.jpg
in its original form, use the following:
1// Returns: "https://upcdn.io/1234abc/raw/example.jpg" 2UrlBuilder.url({ 3 accountId: "1234abc", 4 filePath: "/example.jpg" 5});
Images
To resize the uploaded image /example.jpg
to 800x600, use the following:
1// Returns: "https://upcdn.io/1234abc/image/example.jpg?w=800&h=600" 2UrlBuilder.url({ 3 accountId: "1234abc", 4 filePath: "/example.jpg", 5 options: { 6 transformation: "image", 7 transformationParams: { 8 w: 800, 9 h: 600 10 } 11 } 12});
Videos
To transcode the uploaded video /example.mov
to MP4/H.264 in HD, use the following:
1// Returns: "https://upcdn.io/1234abc/video/example.mov?f=mp4-h264&h=1080" 2UrlBuilder.url({ 3 accountId: "1234abc", 4 filePath: "/example.mov", 5 options: { 6 transformation: "video", 7 transformationParams: { 8 f: "mp4-h264", 9 h: 1080 10 } 11 } 12});
Audio
To transcode the uploaded audio /example.wav
to AAC in 192kbps, use the following:
1// Returns: "https://upcdn.io/1234abc/audio/example.wav?f=aac&br=192" 2UrlBuilder.url({ 3 accountId: "1234abc", 4 filePath: "/example.wav", 5 options: { 6 transformation: "audio", 7 transformationParams: { 8 f: "aac", 9 br: 192 10 } 11 } 12});
Archives
To extract the file document.docx
from the uploaded ZIP file /example.zip
:
1// Returns: "https://upcdn.io/1234abc/archive/example.zip?m=extract&artifact=/document.docx" 2UrlBuilder.url({ 3 accountId: "1234abc", 4 filePath: "/example.zip", 5 options: { 6 transformation: "archive", 7 transformationParams: { 8 m: "extract" 9 }, 10 artifact: "/document.docx" 11 } 12});
🙋 Can I use my own storage?
Bytescale supports AWS S3, Cloudflare R2, Google Storage, DigitalOcean, and Bytescale Storage.
👋 Create your Bytescale Account
Bytescale is the best way to upload, transform, and serve images, videos, and audio at scale.
Full Documentation
- Bytescale Upload Widget Docs »
- Bytescale Upload Widget (React) Docs »
- Bytescale Upload Widget (Angular) Docs »
- Bytescale Upload Widget (Vue.js) Docs »
- Bytescale Upload Widget (jQuery) Docs »
License
No vulnerabilities found.
No security vulnerabilities found.