0.2.0 • Published 4 years ago

@netology-group/storage v0.2.0

Weekly downloads
229
License
MIT
Repository
github
Last release
4 years ago

StorageJS

JavaScript API-client for Storage service

Installation

npm install --save @netology-group/storage

Example

import {
  AxiosHttpClient,
  SimpleTokenProvider,
  HttpStorageResource
} from '@netology-group/storage'

const TOKEN = 'jwt-token'
const bucket = 'example-bucket'
const set = '123'
const object = 'example.json'
const headers = {
  'cache-control': 'max-age=31536000',
  'content-type': 'application/json'
}
const data = {foo: 'bar'}

const storage = new HttpStorageResource(
  'https://example.com',
  'api/v1',
  new AxiosHttpClient(),
  new SimpleTokenProvider(TOKEN)
)

// signing request params
storage.sign({ method: 'PUT', bucket, set, object, headers })
  .then((response) => {
    console.log('[response]', response)
  })
  .catch((error) => {
    console.log('[error]', error)
  })
  
// uploading data
storage.upload({ bucket, set, object, headers }, data, {})
  .then((response) => {
    console.log('[response]', response)
  })
  .catch((error) => {
    console.log('[error]', error)
  })
0.2.0

4 years ago

0.2.0-dev.0

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.1.0-alpha.2

5 years ago

0.1.0-alpha.1

5 years ago