{"id":13455195,"url":"https://github.com/bytescale/bytescale-javascript-sdk","last_synced_at":"2025-03-24T08:31:37.955Z","repository":{"id":45960329,"uuid":"320881166","full_name":"bytescale/bytescale-javascript-sdk","owner":"bytescale","description":"Official Bytescale JavaScript SDK","archived":false,"fork":false,"pushed_at":"2024-10-11T11:53:08.000Z","size":2445,"stargazers_count":85,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-11T11:55:11.592Z","etag":null,"topics":["file","file-upload","file-uploader","image-upload","image-uploader","javascript","javascript-library","library","npm-package","upload","upload-library"],"latest_commit_sha":null,"homepage":"https://www.bytescale.com/docs/sdks/javascript","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytescale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-12T17:04:49.000Z","updated_at":"2024-10-11T11:51:40.000Z","dependencies_parsed_at":"2023-08-15T18:04:08.769Z","dependency_job_id":"9b84cbe3-5555-43f9-9594-02be8f7a9288","html_url":"https://github.com/bytescale/bytescale-javascript-sdk","commit_stats":null,"previous_names":["bytescale/upload-js","bytescale/bytescale-javascript-sdk"],"tags_count":195,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytescale%2Fbytescale-javascript-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytescale%2Fbytescale-javascript-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytescale%2Fbytescale-javascript-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytescale%2Fbytescale-javascript-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytescale","download_url":"https://codeload.github.com/bytescale/bytescale-javascript-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221947443,"owners_count":16906130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file","file-upload","file-uploader","image-upload","image-uploader","javascript","javascript-library","library","npm-package","upload","upload-library"],"created_at":"2024-07-31T08:01:02.309Z","updated_at":"2024-10-28T22:30:38.507Z","avatar_url":"https://github.com/bytescale.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://www.bytescale.com/docs/sdks/javascript\"\u003e\n    \u003cimg alt=\"Bytescale JavaScript SDK\" width=\"467\" height=\"80\" src=\"https://raw.githubusercontent.com/bytescale/bytescale-javascript-sdk/main/.github/assets/bytescale-javascript-sdk.svg\"\u003e\n  \u003c/a\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@bytescale/sdk\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/%40bytescale%2Fsdk-npm-4ba0f6\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/bytescale/bytescale-javascript-sdk/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/build-passing-4ba0f6\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/bytescale/bytescale-javascript-sdk/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/gzipped-9%20kb-4ba0f6\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://www.npmjs.com/package/@bytescale/sdk\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/upload-js?color=%234ba0f6\" /\u003e\n  \u003c/a\u003e\n  \u003cbr/\u003e\n\n  \u003ca href=\"https://www.npmjs.com/package/@bytescale/sdk\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/TypeScript-included-4ba0f6\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/bytescale/bytescale-javascript-sdk/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/npms-io/maintenance-score/upload-js?color=4ba0f6\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca target=\"_blank\" href=\"https://twitter.com/intent/tweet?text=This%20was%20a%20great%20find...%0A%0Ahttps%3A%2F%2Fgithub.com%2Fbytescale%2Fbytescale-javascript-sdk\"\u003e\n    \u003cimg alt=\"Twitter URL\" src=\"https://img.shields.io/twitter/url?style=social\u0026url=https%3A%2F%2Fgithub.com%2Fbytescale%2Fbytescale-javascript-sdk\" /\u003e\n  \u003c/a\u003e\n\n\u003c/p\u003e\n\n\u003chr/\u003e\n\n\u003cp align=\"center\"\u003e\n  Use the Bytescale JavaScript SDK to upload, transform, and serve files at scale.\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003ca href=\"https://www.bytescale.com/docs/sdks/javascript\" rel=\"nofollow\"\u003e\u003cb\u003eFull SDK Documentation\u003c/b\u003e\u003c/a\u003e • \u003ca href=\"https://www.bytescale.com/docs/upload-widget\" rel=\"nofollow\"\u003eUpload Widget\u003c/a\u003e • \u003ca href=\"https://www.bytescale.com/docs/media-processing-apis\" rel=\"nofollow\"\u003eMedia Processing APIs\u003c/a\u003e • \u003ca href=\"https://www.bytescale.com/docs/storage/sources\" rel=\"nofollow\"\u003eStorage\u003c/a\u003e • \u003ca href=\"https://www.bytescale.com/docs/cdn\" rel=\"nofollow\"\u003eCDN\u003c/a\u003e\n\u003c/p\u003e\n\n\u003chr/\u003e\n\n\u003cimg alt=\"Bytescale JavaScript SDK Example\" src=\"https://raw.githubusercontent.com/bytescale/bytescale-javascript-sdk/main/.github/assets/bytescale-javascript-sdk-2.png\"\u003e\n\n## Installation\n\n#### For Node.js:\n\n```bash\nnpm install @bytescale/sdk node-fetch\n```\n\n#### For Browsers:\n\n```bash\nnpm install @bytescale/sdk\n```\n\nIf you'd prefer to use a script tag:\n\n```html\n\u003cscript src=\"https://js.bytescale.com/sdk/v3\"\u003e\u003c/script\u003e\n```\n\n## Uploading Files — [Try on CodePen](https://codepen.io/bytescale/pen/abVapaJ?editors=1010)\n\nThis library is isomorphic, meaning you can upload files from Node.js, or the browser, or both.\n\n#### From Node.js:\n\n```javascript\nimport * as Bytescale from \"@bytescale/sdk\";\nimport nodeFetch from \"node-fetch\";\n\nconst uploadManager = new Bytescale.UploadManager({\n  fetchApi: nodeFetch, // import nodeFetch from \"node-fetch\"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.\n  apiKey: \"free\" // Get API keys from: www.bytescale.com\n});\n\nuploadManager\n  .upload({\n    // Supported types:\n    // - String\n    // - Blob\n    // - ArrayBuffer\n    // - Buffer\n    // - ReadableStream (Node.js), e.g. fs.createReadStream(\"file.txt\")\n    data: \"Hello World\",\n\n    // ---------\n    // Optional:\n    // ---------\n\n    // Required if 'data' is a stream.\n    // size: 5098, // e.g. fs.statSync(\"file.txt\").size\n\n    // Required if 'data' is a stream, buffer, or string.\n    mime: \"text/plain\",\n\n    // Required if 'data' is a stream, buffer, or string.\n    originalFileName: \"my_file.txt\"\n\n    // Reports progress: bytesTotal, bytesSent, progress.\n    // onProgress: ({ progress }) =\u003e console.log(progress),\n\n    // Controls multipart upload concurrency. Ignored if 'data' is a stream.\n    // maxConcurrentUploadParts: 4,\n\n    // Up to 2KB of arbitrary JSON.\n    // metadata: {\n    //   productId: 60891\n    // },\n\n    // Up to 25 tags per file.\n    // tags: [\n    //   \"example_tag\"\n    // ],\n\n    // About file paths:\n    // - Your API key's \"file upload path\" is used by default, and can be changed by editing the API key's settings.\n    // - You can override the API key's file upload path by specifying a path below.\n    // - You may use path variables (e.g. \"{UTC_DAY}\"): http://localhost:3201/docs/path-variables\n    // path: {\n    //   folderPath: \"/uploads/{UTC_YEAR}/{UTC_MONTH}/{UTC_DAY}\",\n    //   fileName: \"{UTC_TIME_TOKEN_INVERSE}{UNIQUE_DIGITS_2}{ORIGINAL_FILE_EXT}\"\n    // },\n\n    // Set to 'isCancelled = true' after invoking 'upload' to cancel the upload.\n    // cancellationToken: {\n    //   isCancelled: false\n    // }\n  })\n  .then(\n    ({ fileUrl, filePath }) =\u003e {\n      // --------------------------------------------\n      // File successfully uploaded!\n      // --------------------------------------------\n      // The 'filePath' uniquely identifies the file,\n      // and is what you should save to your DB.\n      // --------------------------------------------\n      console.log(`File uploaded to: ${fileUrl}`);\n    },\n    error =\u003e console.error(`Error: ${error.message}`, error)\n  );\n```\n\n#### From the Browser:\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript src=\"https://js.bytescale.com/sdk/v3\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      // import * as Bytescale from \"@bytescale/sdk\"\n      const uploadManager = new Bytescale.UploadManager({\n        apiKey: \"free\" // Get API keys from: www.bytescale.com\n      });\n\n      const onFileSelected = async event =\u003e {\n        const file = event.target.files[0];\n\n        try {\n          const { fileUrl, filePath } = await uploadManager.upload({\n            // Supported types:\n            // - String\n            // - Blob\n            // - ArrayBuffer\n            // - File (i.e. from a DOM file input element)\n            data: file\n\n            // ---------\n            // Optional:\n            // ---------\n\n            // Required if 'data' is a stream. Node.js only. (Not required when uploading files from the browser.)\n            // size: 5098, // e.g. fs.statSync(\"file.txt\").size\n\n            // Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)\n            // mime: \"application/octet-stream\",\n\n            // Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)\n            // originalFileName: \"my_file.txt\",\n\n            // Reports progress: bytesTotal, bytesSent, progress.\n            // onProgress: ({ progress }) =\u003e console.log(progress),\n\n            // Controls multipart upload concurrency. Ignored if 'data' is a stream.\n            // maxConcurrentUploadParts: 4,\n\n            // Up to 2KB of arbitrary JSON.\n            // metadata: {\n            //   productId: 60891\n            // },\n\n            // Up to 25 tags per file.\n            // tags: [\n            //   \"example_tag\"\n            // ],\n\n            // About file paths:\n            // - Your API key's \"file upload path\" is used by default, and can be changed by editing the API key's settings.\n            // - You can override the API key's file upload path by specifying a path below.\n            // - You may use path variables (e.g. \"{UTC_DAY}\"): http://localhost:3201/docs/path-variables\n            // path: {\n            //   folderPath: \"/uploads/{UTC_YEAR}/{UTC_MONTH}/{UTC_DAY}\",\n            //   fileName: \"{UTC_TIME_TOKEN_INVERSE}{UNIQUE_DIGITS_2}{ORIGINAL_FILE_EXT}\"\n            // },\n\n            // Set to 'isCancelled = true' after invoking 'upload' to cancel the upload.\n            // cancellationToken: {\n            //   isCancelled: false\n            // }\n          });\n\n          // --------------------------------------------\n          // File successfully uploaded!\n          // --------------------------------------------\n          // The 'filePath' uniquely identifies the file,\n          // and is what you should save to your API.\n          // --------------------------------------------\n          alert(`File uploaded:\\n${fileUrl}`);\n        } catch (e) {\n          alert(`Error:\\n${e.message}`);\n        }\n      };\n    \u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cinput type=\"file\" onchange=\"onFileSelected(event)\" /\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Downloading Files\n\n```javascript\nimport * as Bytescale from \"@bytescale/sdk\";\nimport nodeFetch from \"node-fetch\"; // Only required for Node.js\n\nconst fileApi = new Bytescale.FileApi({\n  fetchApi: nodeFetch, // import nodeFetch from \"node-fetch\"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.\n  apiKey: \"YOUR_API_KEY\" // e.g. \"secret_xxxxx\"\n});\n\nfileApi\n  .downloadFile({\n    accountId: \"YOUR_ACCOUNT_ID\", // e.g. \"W142hJk\"\n    filePath: \"/uploads/2022/12/25/hello_world.txt\"\n  })\n  .then(response =\u003e response.text()) // .text() | .json() | .blob() | .stream()\n  .then(\n    fileContents =\u003e console.log(fileContents),\n    error =\u003e console.error(error)\n  );\n```\n\nUse the [`UrlBuilder`](#urlbuilder) to get a URL instead (if you need a file URL instead of a binary stream).\n\n## Processing Files\n\n```javascript\nimport * as Bytescale from \"@bytescale/sdk\";\nimport fetch from \"node-fetch\"; // Only required for Node.js\nimport fs from \"fs\";\n\nconst fileApi = new Bytescale.FileApi({\n  fetchApi: nodeFetch, // import nodeFetch from \"node-fetch\"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.\n  apiKey: \"YOUR_API_KEY\" // e.g. \"secret_xxxxx\"\n});\n\nfileApi\n  .processFile({\n    accountId: \"YOUR_ACCOUNT_ID\", // e.g. \"W142hJk\"\n    filePath: \"/uploads/2022/12/25/image.jpg\",\n\n    // See: https://www.bytescale.com/docs/image-processing-api\n    transformation: \"image\",\n    transformationParams: {\n      w: 800,\n      h: 600\n    }\n  })\n  .then(response =\u003e response.stream()) // .text() | .json() | .blob() | .stream()\n  .then(\n    imageByteStream =\u003e\n      new Promise((resolve, reject) =\u003e {\n        const writer = fs.createWriteStream(\"image-thumbnail.jpg\");\n        writer.on(\"close\", resolve);\n        writer.on(\"error\", reject);\n        imageByteStream.pipe(writer);\n      })\n  )\n  .then(\n    () =\u003e console.log(\"Thumbnail saved to 'image-thumbnail.jpg'\"),\n    error =\u003e console.error(error)\n  );\n```\n\nUse the [`UrlBuilder`](#urlbuilder) to get a URL instead (if you need a file URL instead of a binary stream).\n\n## Get File Details\n\n```javascript\nimport * as Bytescale from \"@bytescale/sdk\";\nimport fetch from \"node-fetch\"; // Only required for Node.js\n\nconst fileApi = new Bytescale.FileApi({\n  fetchApi: nodeFetch, // import nodeFetch from \"node-fetch\"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.\n  apiKey: \"YOUR_API_KEY\" // e.g. \"secret_xxxxx\"\n});\n\nfileApi\n  .getFileDetails({\n    accountId: \"YOUR_ACCOUNT_ID\", // e.g. \"W142hJk\"\n    filePath: \"/uploads/2022/12/25/image.jpg\"\n  })\n  .then(\n    fileDetails =\u003e console.log(fileDetails),\n    error =\u003e console.error(error)\n  );\n```\n\n## Listing Folders\n\n```javascript\nimport * as Bytescale from \"@bytescale/sdk\";\nimport fetch from \"node-fetch\"; // Only required for Node.js\n\nconst folderApi = new Bytescale.FolderApi({\n  fetchApi: nodeFetch, // import nodeFetch from \"node-fetch\"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.\n  apiKey: \"YOUR_API_KEY\" // e.g. \"secret_xxxxx\"\n});\n\nfolderApi\n  .listFolder({\n    accountId: \"YOUR_ACCOUNT_ID\", // e.g. \"W142hJk\"\n    folderPath: \"/\",\n    recursive: false\n  })\n  .then(\n    // Note: operation is paginated, see 'result.cursor' and 'params.cursor'.\n    result =\u003e console.log(`Items in folder: ${result.items.length}`),\n    error =\u003e console.error(error)\n  );\n```\n\n## 📙 Bytescale SDK API Reference\n\nFor a complete list of operations, please see:\n\n**[Bytescale JavaScript SDK Docs »](https://www.bytescale.com/docs/sdks/javascript)**\n\n## 🌐 Media Processing APIs (Image/Video/Audio)\n\nBytescale provides several real-time [Media Processing APIs](https://www.bytescale.com/docs/media-processing-apis):\n\n- **[Image Processing APIs](https://www.bytescale.com/docs/image-processing-api)** ([resize](https://www.bytescale.com/docs/image-processing-api#image-resizing-api), [crop](https://www.bytescale.com/docs/image-processing-api#image-cropping-api), [convert](https://www.bytescale.com/docs/image-processing-api#f), [compress](https://www.bytescale.com/docs/image-processing-api#image-compression-api) \u0026 [watermark](https://www.bytescale.com/docs/image-processing-api#Text-layering-api))\n- **[Video Processing APIs](https://www.bytescale.com/docs/video-processing-api)** ([transcode](https://www.bytescale.com/docs/video-processing-api#video-transcoding-api), [optimize](https://www.bytescale.com/docs/video-processing-api#video-compression-api), [resize](https://www.bytescale.com/docs/video-processing-api#video-resizing-api) \u0026 [extract metadata](https://www.bytescale.com/docs/video-processing-api#video-metadata-api))\n- **[Audio Processing APIs](https://www.bytescale.com/docs/audio-processing-api)** ([transcode](https://www.bytescale.com/docs/audio-processing-api#audio-transcoding-api), [optimize](https://www.bytescale.com/docs/audio-processing-api#audio-compression-api), [trim](https://www.bytescale.com/docs/audio-processing-api#audio-trimming-api) \u0026 [extract metadata](https://www.bytescale.com/docs/audio-processing-api#audio-metadata-api))\n\n### Image Processing API (Original Image)\n\nHere's an example using [a photo of Chicago](https://upcdn.io/W142hJk/raw/example/city-landscape.jpg):\n\n\u003cimg src=\"https://upcdn.io/W142hJk/raw/example/city-landscape.jpg\" /\u003e\n\n```\nhttps://upcdn.io/W142hJk/raw/example/city-landscape.jpg\n```\n\n### Image Processing API (Transformed Image)\n\nUsing the [Image Processing API](https://www.bytescale.com/docs/image-processing-api), you can produce [this image](https://upcdn.io/W142hJk/image/example/city-landscape.jpg?w=900\u0026h=600\u0026fit=crop\u0026f=webp\u0026q=80\u0026blur=4\u0026text=WATERMARK\u0026layer-opacity=80\u0026blend=overlay\u0026layer-rotate=315\u0026font-size=100\u0026padding=10\u0026font-weight=900\u0026color=ffffff\u0026repeat=true\u0026text=Chicago\u0026gravity=bottom\u0026padding-x=50\u0026padding-bottom=20\u0026font=/example/fonts/Lobster.ttf\u0026color=ffe400):\n\n\u003cimg src=\"https://upcdn.io/W142hJk/image/example/city-landscape.jpg?w=900\u0026h=600\u0026fit=crop\u0026f=webp\u0026q=80\u0026blur=4\u0026text=WATERMARK\u0026layer-opacity=80\u0026blend=overlay\u0026layer-rotate=315\u0026font-size=100\u0026padding=10\u0026font-weight=900\u0026color=ffffff\u0026repeat=true\u0026text=Chicago\u0026gravity=bottom\u0026padding-x=50\u0026padding-bottom=20\u0026font=/example/fonts/Lobster.ttf\u0026color=ffe400\" /\u003e\n\n```\nhttps://upcdn.io/W142hJk/image/example/city-landscape.jpg\n  ?w=900\n  \u0026h=600\n  \u0026fit=crop\n  \u0026f=webp\n  \u0026q=80\n  \u0026blur=4\n  \u0026text=WATERMARK\n  \u0026layer-opacity=80\n  \u0026blend=overlay\n  \u0026layer-rotate=315\n  \u0026font-size=100\n  \u0026padding=10\n  \u0026font-weight=900\n  \u0026color=ffffff\n  \u0026repeat=true\n  \u0026text=Chicago\n  \u0026gravity=bottom\n  \u0026padding-x=50\n  \u0026padding-bottom=20\n  \u0026font=/example/fonts/Lobster.ttf\n  \u0026color=ffe400\n```\n\n## Authentication\n\nThe Bytescale JavaScript SDK supports two types of authentication:\n\n### API Keys\n\nThe Bytescale JavaScript SDK automatically adds the `apiKey` from the constructor to the `authorization` header for all requests made via the SDK.\n\nWith API key auth, the requester has access to the resources available to the API key:\n\n- Secret API keys (`secret_***`) can perform all API operations.\n\n- 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.\n\nEach Public API Key and Secret API Key can have its read/write access limited to a subset of files/folders.\n\n### JWTs\n\nJWTs are optional.\n\nWith JWTs, the user 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 `\u003cimg\u003e`, `\u003cvideo\u003e`, and other elements.\n\nWith JWTs, the user can also perform API requests, such as file deletions, as these can be granted by the [JWT's payload](https://www.bytescale.com/docs/types/BytescaleJwt). The Bytescale JavaScript SDK will automatically inject the user's JWT into the `authorization-token` request header for all API requests, assuming the `AuthManager.beginAuthSession` method has been called.\n\n[Learn more about the `AuthManager` and JWTs »](https://www.bytescale.com/docs/auth)\n\n## UrlBuilder\n\nUse the `UrlBuilder` to construct URLs for your uploaded files:\n\n```javascript\nimport { UrlBuilder } from \"@bytescale/sdk\";\n```\n\n#### Raw Files\n\nTo get the URL for the uploaded image `/example.jpg` in its original form, use the following:\n\n```javascript\n// Returns: \"https://upcdn.io/1234abc/raw/example.jpg\"\nUrlBuilder.url({\n  accountId: \"1234abc\",\n  filePath: \"/example.jpg\"\n});\n```\n\n#### Images\n\nTo resize the uploaded image `/example.jpg` to 800x600, use the following:\n\n```javascript\n// Returns: \"https://upcdn.io/1234abc/image/example.jpg?w=800\u0026h=600\"\nUrlBuilder.url({\n  accountId: \"1234abc\",\n  filePath: \"/example.jpg\",\n  options: {\n    transformation: \"image\",\n    transformationParams: {\n      w: 800,\n      h: 600\n    }\n  }\n});\n```\n\n[Image Processing API Docs »](https://www.bytescale.com/docs/image-processing-api)\n\n#### Videos\n\nTo transcode the uploaded video `/example.mov` to MP4/H.264 in HD, use the following:\n\n```javascript\n// Returns: \"https://upcdn.io/1234abc/video/example.mov?f=mp4-h264\u0026h=1080\"\nUrlBuilder.url({\n  accountId: \"1234abc\",\n  filePath: \"/example.mov\",\n  options: {\n    transformation: \"video\",\n    transformationParams: {\n      f: \"mp4-h264\",\n      h: 1080\n    }\n  }\n});\n```\n\n[Video Processing API Docs »](https://www.bytescale.com/docs/video-processing-api)\n\n#### Audio\n\nTo transcode the uploaded audio `/example.wav` to AAC in 192kbps, use the following:\n\n```javascript\n// Returns: \"https://upcdn.io/1234abc/audio/example.wav?f=aac\u0026br=192\"\nUrlBuilder.url({\n  accountId: \"1234abc\",\n  filePath: \"/example.wav\",\n  options: {\n    transformation: \"audio\",\n    transformationParams: {\n      f: \"aac\",\n      br: 192\n    }\n  }\n});\n```\n\n[Audio Processing API Docs »](https://www.bytescale.com/docs/audio-processing-api)\n\n#### Archives\n\nTo extract the file `document.docx` from the uploaded ZIP file `/example.zip`:\n\n```javascript\n// Returns: \"https://upcdn.io/1234abc/archive/example.zip?m=extract\u0026artifact=/document.docx\"\nUrlBuilder.url({\n  accountId: \"1234abc\",\n  filePath: \"/example.zip\",\n  options: {\n    transformation: \"archive\",\n    transformationParams: {\n      m: \"extract\"\n    },\n    artifact: \"/document.docx\"\n  }\n});\n```\n\n[Archive Processing API Docs »](https://www.bytescale.com/docs/archive-processing-api)\n\n#### Antivirus\n\nTo scan the file `example.zip` for viruses, use the following:\n\n```javascript\n// Returns: \"https://upcdn.io/1234abc/antivirus/example.zip\"\nUrlBuilder.url({\n  accountId: \"1234abc\",\n  filePath: \"/example.zip\",\n  options: {\n    transformation: \"antivirus\"\n  }\n});\n```\n\n[Antivirus API Docs »](https://www.bytescale.com/docs/antivirus-api)\n\n## 🙋 Can I use my own storage?\n\nBytescale supports AWS S3, Cloudflare R2, Google Storage, DigitalOcean, and Bytescale Storage.\n\n**[Bytescale Storage Docs »](https://www.bytescale.com/docs/storage/sources)**\n\n**[Bytescale JavaScript SDK Docs »](https://www.bytescale.com/docs/sdks/javascript)**\n\n## 👋 Create your Bytescale Account\n\nBytescale is the best way to upload, transform, and serve images, videos, and audio at scale.\n\n**[Create a Bytescale account »](https://www.bytescale.com/get-started)**\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytescale%2Fbytescale-javascript-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytescale%2Fbytescale-javascript-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytescale%2Fbytescale-javascript-sdk/lists"}