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

mediacloud-server-client

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mediacloud-server-client

A TypeScript package for uploading files to Media Cloud API

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Media Cloud Uploader

A TypeScript package for uploading files to the Media Cloud API, fetching uploaded media, and deleting media.

Installation

npm install media-cloud-uploader

Usage

import { MediaCloudUploader } from 'media-cloud-uploader';

async function main() {
  const uploader = new MediaCloudUploader('your-api-key');

  try {
    // Upload a file
    const imageUrl = await uploader.uploadFile({
      filePath: '/path/to/your/file.jpg',
      optimize: true
    });
    console.log('Uploaded image URL:', imageUrl);

    // Fetch uploaded media
    const uploadedMedia = await uploader.getUploadedMedia();
    console.log('Uploaded media:', uploadedMedia);

    // Delete a media item
    const mediaIdToDelete = 'bWVkaWEvaW1hZ2VzL29yaWdpbmFsL3JqMExYTUlPOUtLSDc2UXRwZkRIeEJ6NGwzN1VIb01aVWdUbnR0cVcucG5n';
    await uploader.deleteMedia(mediaIdToDelete);
    console.log('Media deleted successfully');
  } catch (error) {
    console.error('Operation failed:', error);
  }
}

main();

API

MediaCloudUploader

A class that handles file uploads to the Media Cloud API, fetches uploaded media, and deletes media.

Constructor
new MediaCloudUploader(apiKey: string)
  • apiKey (string): Your Media Cloud API key.
Methods
uploadFile(options: UploadOptions): Promise<string>

Uploads a file to the Media Cloud API.

Options
  • filePath (string): The path to the file you want to upload.
  • optimize (boolean, optional): Whether to optimize the uploaded media. Defaults to true.
Returns

A promise that resolves to the URL of the uploaded media.

getUploadedMedia(page?: number): Promise<PaginatedMediaResponse>

Fetches the list of uploaded media from the Media Cloud API.

Parameters
  • page (number, optional): The page number of results to fetch. Defaults to 1.
Returns

A promise that resolves to a PaginatedMediaResponse object containing the list of media URLs and pagination information.

deleteMedia(mediaId: string): Promise<void>

Deletes a specific media item from the Media Cloud API.

Parameters
  • mediaId (string): The ID of the media item to delete. This is the last part of the media URL after /media/.
Returns

A promise that resolves when the media item is successfully deleted.

Types

MediaItem

A string representing the URL of an uploaded media item.

PaginatedMediaResponse

An object containing the paginated list of media items and related pagination information.

License

MIT

mediacloud-server-client

Keywords

FAQs

Package last updated on 22 Jul 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