@bytescale/sdk
Advanced tools
Comparing version 3.0.0-alpha.11 to 3.0.0-alpha.12
{ | ||
"name": "@bytescale/sdk", | ||
"version": "3.0.0-alpha.11", | ||
"version": "3.0.0-alpha.12", | ||
"description": "Bytescale JavaScript SDK", | ||
@@ -16,2 +16,6 @@ "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)", | ||
}, | ||
"worker": { | ||
"require": "./dist/node/cjs/main.js", | ||
"import": "./dist/node/esm/main.mjs" | ||
}, | ||
"default": "./dist/browser/cjs/main.js" | ||
@@ -18,0 +22,0 @@ } |
@@ -53,2 +53,4 @@ <h1 align="center"> | ||
<img alt="Bytescale JavaScript SDK Example" src="https://raw.githubusercontent.com/bytescale/bytescale-javascript-sdk/main/.github/assets/bytescale-javascript-sdk.png"> | ||
## Installation | ||
@@ -82,6 +84,6 @@ | ||
import * as Bytescale from "@bytescale/sdk"; | ||
import fetch from "node-fetch"; | ||
import nodeFetch from "node-fetch"; | ||
const uploadManager = new Bytescale.UploadManager({ | ||
fetchApi: fetch, // or 'fetch as any' (please note: you must use 'node-fetch' as errors can occur with other implementations) | ||
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js // Errors can occur with other implementations // Try 'nodeFetch as any' for TypeScript | ||
apiKey: "free" // Get API keys from: www.bytescale.com | ||
@@ -92,7 +94,3 @@ }); | ||
.upload({ | ||
// --------- | ||
// Required: | ||
// --------- | ||
// Supported types for 'data' field: | ||
// Supported types: | ||
// - String | ||
@@ -166,3 +164,3 @@ // - Buffer | ||
const uploadManager = new Bytescale.UploadManager({ | ||
apiKey: "YOUR_API_KEY" // e.g. "public_xxxxx" | ||
apiKey: "free" // Get API keys from: www.bytescale.com | ||
}); | ||
@@ -175,10 +173,3 @@ | ||
const { fileUrl, filePath } = await uploadManager.upload({ | ||
// --------- | ||
// Required: | ||
// --------- | ||
// Your account ID (e.g. "W142hJk") | ||
accountId: "YOUR_ACCOUNT_ID", | ||
// Supported types for 'data' field: | ||
// Supported types: | ||
// - String | ||
@@ -253,7 +244,7 @@ // - Blob | ||
import * as Bytescale from "@bytescale/sdk"; | ||
import fetch from "node-fetch"; // Only required for Node.js | ||
import nodeFetch from "node-fetch"; // Only required for Node.js | ||
const fileApi = new Bytescale.FileApi({ | ||
fetchApi: fetch, // 'fetch as any' for TypeScript | ||
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx" | ||
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js // Errors can occur with other implementations // Try 'nodeFetch as any' for TypeScript | ||
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx" | ||
}); | ||
@@ -263,3 +254,3 @@ | ||
.downloadFile({ | ||
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk" | ||
accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk" | ||
filePath: "/uploads/2022/12/25/hello_world.txt" | ||
@@ -281,6 +272,7 @@ }) | ||
import fetch from "node-fetch"; // Only required for Node.js | ||
import fs from "fs"; | ||
const fileApi = new Bytescale.FileApi({ | ||
fetchApi: fetch, // 'fetch as any' for TypeScript | ||
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx" | ||
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js // Errors can occur with other implementations // Try 'nodeFetch as any' for TypeScript | ||
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx" | ||
}); | ||
@@ -290,3 +282,3 @@ | ||
.processFile({ | ||
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk" | ||
accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk" | ||
filePath: "/uploads/2022/12/25/image.jpg", | ||
@@ -326,4 +318,4 @@ | ||
const fileApi = new Bytescale.FileApi({ | ||
fetchApi: fetch, // 'fetch as any' for TypeScript | ||
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx" | ||
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js // Errors can occur with other implementations // Try 'nodeFetch as any' for TypeScript | ||
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx" | ||
}); | ||
@@ -333,3 +325,3 @@ | ||
.getFileDetails({ | ||
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk" | ||
accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk" | ||
filePath: "/uploads/2022/12/25/image.jpg" | ||
@@ -350,4 +342,4 @@ }) | ||
const folderApi = new Bytescale.FolderApi({ | ||
fetchApi: fetch, // 'fetch as any' for TypeScript | ||
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx" | ||
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js // Errors can occur with other implementations // Try 'nodeFetch as any' for TypeScript | ||
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx" | ||
}); | ||
@@ -357,3 +349,3 @@ | ||
.listFolder({ | ||
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk" | ||
accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk" | ||
folderPath: "/", | ||
@@ -369,2 +361,8 @@ recursive: false | ||
## More Operations | ||
For a complete list of operations, please see: | ||
**[Bytescale JavaScript SDK Docs »](https://www.bytescale.com/docs/sdks/javascript)** | ||
## Authorization | ||
@@ -371,0 +369,0 @@ |
571391
503