New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@filesonfly/node-sdk

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@filesonfly/node-sdk

NodeJS SDK for Files on Fly

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

FilesOnFly Node.js SDK

Unit Tests

The @filesonfly/node-sdk is a Node.js client library for interacting with the FilesOnFly API, allowing you to easily upload, retrieve, and manage files in your Node.js applications.

Features

  • Authenticate and connect to the FilesOnFly API
  • Upload files to the FilesOnFly storage
  • Retrieve file information by file name or ID

Installation

Install the SDK with npm:

npm install @filesonfly/node-sdk

Or with yarn:

yarn add @filesonfly/node-sdk

Usage

Initializing the SDK

First, require and initialize the FilesOnFlySDK:

const FilesOnFlySDK = require('@filesonfly/node-sdk');

const fof = new FilesOnFlySDK('https://api.filesonfly.com');

Connecting to the API

To use the SDK, you must first connect to the API with your authentication token:

const authToken = 'your-auth-token';
await fof.connect(authToken);

Uploading a File

Upload a file using the sendFile method:

const fs = require('fs');

const fileName = 'example.png';
const fileBuffer = fs.readFileSync('/path/to/your/file.png');

await fof.sendFile(fileName, fileBuffer);

Retrieving File Information

Get file information using the getFile method by file name or ID:

// Get by file name
const fileInfoByName = await fof.getFile('example.png');

// Get by file ID
const fileInfoById = await fof.getFile(1);

Error Handling

The SDK throws FoF_Exception errors when API requests fail or validation errors occur. Use try-catch blocks to handle these exceptions:

try {
    await fof.sendFile('file_name', fileBuffer);
} catch (error) {
    if (error instanceof FoF_Exception) {
        console.error('FilesOnFly error:', error.message);
    } else {
        console.error('Unexpected error:', error);
    }
}

Contributing

We welcome contributions to the @filesonfly/node-sdk. If you have suggestions or improvements, please fork the repository and submit a pull request.

Keywords

FAQs

Package last updated on 02 Apr 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