-
-
Notifications
You must be signed in to change notification settings - Fork 322
Storage
psanders edited this page Jun 13, 2020
·
6 revisions
Use Fonos Storage, a capability of Fonos Object Storage subsystem, to upload, download, and delete objects.
Kind: global class
Extends: FonosService
See: module:core:FonosService
-
Storage β
FonosService
- new Storage()
- .uploadObject(request)
-
.getObjectURL(request) β
Promise.<string>
Constructs a new Storage object.
Example
const Fonos = require('@fonos/sdk')
const storage = new Fonos.Storage()
storage.uploadObject()
.then(result => {
console.log(result) // successful response
}).catch(e => console.error(e)) // an error occurred
Upload an object to Fonos Object Storage subsystem.
Kind: instance method of Storage
Throws:
- if the path does not exist or if is a directory
- if the bucket does not exist
Param | Type | Description |
---|---|---|
request | Object |
Object with information about the origin and destination of an object |
request.filename | string |
Path to the object to be uploaded |
request.bucket | string |
Directory at the Storage system to save your file. |
Example
const request = {
filename: '/path/to/file',
bucklet: 'hello-monkeys'
}
storage.uploadObject(request)
.then(() => {
console.log(result) // returns and empty Object
}).catch(e => console.error(e)) // an error occurred
Get Object URL.
Kind: instance method of Storage
Returns: Promise.<string>
- localy accessible URL to the object
Throws:
- if bucket or object does not exist
Param | Type | Description |
---|---|---|
request | Object |
Object with information about the location and and name of the requested object |
request.name | string |
The name of the object |
request.bucket | string |
Bucket where object is located save your file. |
Example
const request = {
name: 'object-name',
bucket: 'bucket-name'
}
storage.getObjectURL(request)
.then(result => {
console.log(result)
}).catch(e => console.error(e)) // an error occurred
Copyright (C) 2022 by Fonoster Inc