Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@squarecloud/blob

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squarecloud/blob

Official Square Cloud Blob SDK for NodeJS

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source
Square Cloud Banner

@squarecloud/blob

Official Square Cloud Blob SDK for NodeJS.

Installation

npm install @squarecloud/blob
// or
yarn add @squarecloud/blob
// or
pnpm add @squarecloud/blob

Documentation

Visit our official API documentation for more information about this service.

Getting Started

import { SquareCloudBlob } from "@squarecloud/blob"
// CommonJS => const { SquareCloudBlob } = require("@squarecloud/blob");

const blob = new SquareCloudBlob("Your API Key")
const objects = await blob.objects.list()

Creating an object

  • 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)
Advanced usage with Buffer
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)

Deleting objects

// List of objects to delete (Limit of 100 per request)
const objectsToDelete = [
  "ID/prefix/name1_xxx-xxx.mp4",
  "ID/prefix/name_xxx-xxx-xxx.png"
]

await blob.objects.delete(objectsToDelete)

Extras

Mime types handling
  • 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/plain

Contributing

Feel free to contribute with suggestions or bug reports at our GitHub repository.

Authors

Keywords

FAQs

Package last updated on 13 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc