{"library":"object-storage-client","title":"Metorial Object Storage Client","description":"The `object-storage-client` package provides a TypeScript and JavaScript client library for programmatic interaction with the Metorial Object Storage Service. It offers a comprehensive, promise-based API for managing buckets and objects, including creation, listing, uploading, downloading, and deletion. The current stable version, 0.2.5, indicates it is in early development and pre-1.0 stability, meaning minor versions might introduce breaking changes. Its key differentiators include strong TypeScript support, a direct interface to the Metorial Object Storage backend (which itself supports multiple storage backends like local filesystem, AWS S3, Google Cloud Storage, and Azure Blob Storage), and a straightforward API for asynchronous operations. This client is specifically designed for the Metorial ecosystem, which aims to connect AI agents to various tools and services.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install object-storage-client"],"cli":null},"imports":["import { ObjectStorageClient } from 'object-storage-client';","import { ObjectStorageError } from 'object-storage-client';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { ObjectStorageClient, ObjectStorageError } from 'object-storage-client';\n\nconst client = new ObjectStorageClient('http://localhost:8080');\n\nasync function runObjectStorageDemo() {\n  try {\n    // Create a bucket\n    const bucketName = 'my-unique-test-bucket-' + Date.now();\n    console.log(`Attempting to create bucket: ${bucketName}`);\n    const bucket = await client.createBucket(bucketName);\n    console.log(`Created bucket: ${bucket.name}`);\n\n    // Upload an object\n    const data = Buffer.from('Hello, Object Storage World!');\n    const objectKey = 'hello.txt';\n    console.log(`Uploading object '${objectKey}' to '${bucketName}'`);\n    const obj = await client.putObject(\n      bucketName,\n      objectKey,\n      data,\n      'text/plain',\n      { author: 'AI-Agent' }\n    );\n    console.log(`Uploaded object: ${obj.key} (ETag: ${obj.etag})`);\n\n    // Download an object\n    console.log(`Downloading object '${objectKey}' from '${bucketName}'`);\n    const objData = await client.getObject(bucketName, objectKey);\n    console.log(`Downloaded ${objData.data.length} bytes. Content: ${objData.data.toString()}`);\n\n    // List objects\n    console.log(`Listing objects in '${bucketName}'`);\n    const objects = await client.listObjects(bucketName);\n    for (const item of objects) {\n      console.log(`- ${item.key}: ${item.size} bytes`);\n    }\n\n    // Delete object\n    console.log(`Deleting object '${objectKey}' from '${bucketName}'`);\n    await client.deleteObject(bucketName, objectKey);\n    console.log('Object deleted.');\n\n    // Delete bucket\n    console.log(`Deleting bucket: ${bucketName}`);\n    await client.deleteBucket(bucketName);\n    console.log('Bucket deleted.');\n\n  } catch (error) {\n    if (error instanceof ObjectStorageError) {\n      console.error(`Object Storage API Error: Status ${error.statusCode}, Message: ${error.message}`);\n    } else if (error instanceof Error) {\n      console.error(`Generic Error: ${error.message}`);\n    } else {\n      console.error('An unknown error occurred:', error);\n    }\n  }\n}\n\nrunObjectStorageDemo();","lang":"typescript","description":"This quickstart demonstrates the full lifecycle of object storage operations: creating a bucket, uploading a text file, downloading it, listing objects, and finally deleting both the object and the bucket. It also includes basic error handling for API-specific and generic errors.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}