Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@bytescale/sdk
Advanced tools
The Bytescale JavaScript SDK allows you to quickly integrate your application with Bytescale.
Effortlessly upload, optimize, transform, and host your digital media assets.
npm install @bytescale/sdk
Additional step for Node.js:
npm install node-fetch
Bytescale JavaScript SDK Full Documentation »
import * as Bytescale from "@bytescale/sdk";
import fetch from "node-fetch"; // Node.js only.
const uploadManager = new Bytescale.UploadManager({
fetchApi: fetch, // 'fetch as any' for TypeScript
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
});
uploadManager
.upload({
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
// Supported types for 'data' field:
// - String
// - Blob
// - File (i.e. from a DOM file input element)
// - Buffer
// - ReadableStream (Node.js), e.g. fs.createReadStream("file.txt")
data: "Example Data"
})
.then(
uploadedFile => console.log(uploadedFile),
error => console.error(error)
);
import * as Bytescale from "@bytescale/sdk";
import fetch from "node-fetch"; // Node.js only.
const fileApi = new Bytescale.FileApi({
fetchApi: fetch, // 'fetch as any' for TypeScript
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
});
fileApi
.downloadFile({
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
filePath: "/uploads/2022/12/25/hello_world.txt"
})
.then(response => response.text()) // .text() | .json() | .blob() | .stream()
.then(
fileContents => console.log(fileContents),
error => console.error(error)
);
Note: you can also download files using: https://upcdn.io/{accountId}/raw/{filePath}
import * as Bytescale from "@bytescale/sdk";
import fetch from "node-fetch"; // Node.js only.
const fileApi = new Bytescale.FileApi({
fetchApi: fetch, // 'fetch as any' for TypeScript
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
});
fileApi
.processFile({
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
filePath: "/uploads/2022/12/25/image.jpg",
transformation: "thumbnail" // Create transformations here: https://www.bytescale.com/dashboard/transformations
})
.then(response => response.stream()) // .text() | .json() | .blob() | .stream()
.then(
imageByteStream =>
new Promise((resolve, reject) => {
const writer = fs.createWriteStream("image-thumbnail.jpg");
writer.on("close", resolve);
writer.on("error", reject);
imageByteStream.pipe(writer);
})
)
.then(
() => console.log("Thumbnail saved to 'image-thumbnail.jpg'"),
error => console.error(error)
);
Note: you can also process files using: https://upcdn.io/{accountId}/{transformation}/{filePath}
import * as Bytescale from "@bytescale/sdk";
import fetch from "node-fetch"; // Node.js only.
const fileApi = new Bytescale.FileApi({
fetchApi: fetch, // 'fetch as any' for TypeScript
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
});
fileApi
.getFileDetails({
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
filePath: "/uploads/2022/12/25/image.jpg"
})
.then(
fileDetails => console.log(fileDetails),
error => console.error(error)
);
import * as Bytescale from "@bytescale/sdk";
import fetch from "node-fetch"; // Node.js only.
const folderApi = new Bytescale.FolderApi({
fetchApi: fetch, // 'fetch as any' for TypeScript
apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
});
folderApi
.listFolder({
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
folderPath: "/",
recursive: false
})
.then(
// Note: operation is paginated, see 'result.cursor' and 'params.cursor'.
result => console.log(`Items in folder: ${result.items.length}`),
error => console.error(error)
);
FAQs
Bytescale JavaScript SDK
The npm package @bytescale/sdk receives a total of 11,100 weekly downloads. As such, @bytescale/sdk popularity was classified as popular.
We found that @bytescale/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.