Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@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,873 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 0 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.