Skip to content

Latest commit

 

History

History
268 lines (189 loc) · 10.3 KB

MediaApi.md

File metadata and controls

268 lines (189 loc) · 10.3 KB

MediaApi

All URIs are relative to http://localhost

Method HTTP request Description
deleteMedia DELETE /users/{accountId}/media/{mediaId} Delete Media
getMedia GET /users/{accountId}/media/{mediaId} Get Media
listMedia GET /users/{accountId}/media List Media
uploadMedia PUT /users/{accountId}/media/{mediaId} Upload Media

deleteMedia

deleteMedia()

Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name.

Example

import {
    MediaApi,
    Configuration
} from 'bandwidth-sdk';

const configuration = new Configuration();
const apiInstance = new MediaApi(configuration);

let accountId: string; //This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated.  **When migrating to OAuth authentication, you must use the 7-digit Account ID.**  (default to undefined)
let mediaId: string; //The ID of the media file. (default to undefined)

const { status, data } = await apiInstance.deleteMedia(
    accountId,
    mediaId
);

Parameters

Name Type Description Notes
accountId [string] This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated. When migrating to OAuth authentication, you must use the 7-digit Account ID. defaults to undefined
mediaId [string] The ID of the media file. defaults to undefined

Return type

void (empty response body)

Authorization

Basic, OAuth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getMedia

File getMedia()

Downloads a media file you previously uploaded.

Example

import {
    MediaApi,
    Configuration
} from 'bandwidth-sdk';

const configuration = new Configuration();
const apiInstance = new MediaApi(configuration);

let accountId: string; //This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated.  **When migrating to OAuth authentication, you must use the 7-digit Account ID.**  (default to undefined)
let mediaId: string; //The ID of the media file. (default to undefined)

const { status, data } = await apiInstance.getMedia(
    accountId,
    mediaId
);

Parameters

Name Type Description Notes
accountId [string] This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated. When migrating to OAuth authentication, you must use the 7-digit Account ID. defaults to undefined
mediaId [string] The ID of the media file. defaults to undefined

Return type

File

Authorization

Basic, OAuth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/octet-stream, application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

listMedia

Array listMedia()

Gets a list of your media files. No query parameters are supported.

Example

import {
    MediaApi,
    Configuration
} from 'bandwidth-sdk';

const configuration = new Configuration();
const apiInstance = new MediaApi(configuration);

let accountId: string; //This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated.  **When migrating to OAuth authentication, you must use the 7-digit Account ID.**  (default to undefined)
let continuationToken: string; //Continuation token used to retrieve subsequent media. (optional) (default to undefined)

const { status, data } = await apiInstance.listMedia(
    accountId,
    continuationToken
);

Parameters

Name Type Description Notes
accountId [string] This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated. When migrating to OAuth authentication, you must use the 7-digit Account ID. defaults to undefined
continuationToken [string] Continuation token used to retrieve subsequent media. (optional) defaults to undefined

Return type

Array

Authorization

Basic, OAuth2

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK * Continuation-Token - Continuation token used to retrieve subsequent media.
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

uploadMedia

uploadMedia(body)

Upload a file. Filename should always be unique. Reusing filenames may result in the wrong media being sent. A list of supported media types can be found at Bandwidth Support.

Example

import {
    MediaApi,
    Configuration
} from 'bandwidth-sdk';

const configuration = new Configuration();
const apiInstance = new MediaApi(configuration);

let accountId: string; //This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated.  **When migrating to OAuth authentication, you must use the 7-digit Account ID.**  (default to undefined)
let mediaId: string; //The ID of the media file. (default to undefined)
let body: File; //
let contentType: string; //The media type of the entity-body. (optional) (default to undefined)
let cacheControl: string; //Pass-through header stored with the media and returned when the media is retrieved by the user. Does not affect internal server caching behavior. (optional) (default to undefined)

const { status, data } = await apiInstance.uploadMedia(
    accountId,
    mediaId,
    body,
    contentType,
    cacheControl
);

Parameters

Name Type Description Notes
body File
accountId [string] This is your 7-digit Bandwidth Account ID, as shown in the Bandwidth App. The older ID format (`u-be8dvafwrs63rwpm7pfil4b`) is deprecated. When migrating to OAuth authentication, you must use the 7-digit Account ID. defaults to undefined
mediaId [string] The ID of the media file. defaults to undefined
contentType [string] The media type of the entity-body. (optional) defaults to undefined
cacheControl [string] Pass-through header stored with the media and returned when the media is retrieved by the user. Does not affect internal server caching behavior. (optional) defaults to undefined

Return type

void (empty response body)

Authorization

Basic, OAuth2

HTTP request headers

  • Content-Type: application/json, application/ogg, application/pdf, application/rtf, application/zip, application/x-tar, application/xml, application/gzip, application/x-bzip2, application/x-gzip, application/smil, application/javascript, audio/mp4, audio/mpeg, audio/ogg, audio/flac, audio/webm, audio/wav, audio/amr, audio/3gpp, image/bmp, image/gif, image/heic, image/heif, image/jpeg, image/pjpeg, image/png, image/svg+xml, image/tiff, image/webp, image/x-icon, text/css, text/csv, text/calendar, text/html, text/plain, text/javascript, text/vcard, text/vnd.wap.wml, text/xml, video/avi, video/mp4, video/mpeg, video/ogg, video/quicktime, video/webm, video/x-ms-wmv, video/x-flv
  • Accept: application/json

HTTP response details

Status code Description Response headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]