Official Square Cloud Blob SDK for NodeJS.
npm install @squarecloud/blob
// or
yarn add @squarecloud/blob
// or
pnpm add @squarecloud/blobVisit our official API documentation for more information about this service.
- Login and get your API Key at https://squarecloud.app/account.
import { SquareCloudBlob } from "@squarecloud/blob"
// CommonJS => const { SquareCloudBlob } = require("@squarecloud/blob");
const blob = new SquareCloudBlob("Your API Key")
const objects = await blob.objects.list()- Check supported file types here.
const blobObject = await blob.objects.create({
  file: "path/to/file.png", // Absolute path to your file
  name: "my_image",         // File name without extension
})
console.log(blobObject.url)import { MimeTypes } from "@squarecloud/blob"
// CommonJS => const { MimeTypes } = require("@squarecloud/blob")
const blobObject = await blob.objects.create({
  file: Buffer.from("content"),
  name: "my_image",
  mimeType: MimeTypes.IMAGE_JPEG, // Also accepts an string "image/jpeg"
})
console.log(blobObject.url)await blob.objects.delete("ID/prefix/name1_xxx-xxx.mp4")- Check supported file types here.
import { MimeTypeUtil } from "@squarecloud/blob"
// Get a supported mime type from a file extension
console.log(MimeTypeUtil.fromExtension("jpeg"))   // "image/jpeg"       | Supported
console.log(MimeTypeUtil.fromExtension("json"))   // "application/json" | Supported
console.log(MimeTypeUtil.fromExtension("potato")) // "text/plain"       | Unsupported, defaults to text/plainFeel free to contribute with suggestions or bug reports at our GitHub repository.
