Skip to content

@ubstream/ubstream-node-client-sdk / Exports / MediasDocumentsClient

Class: MediasDocumentsClient

This class provides access to methods concerning media documents.

Hierarchy

  • AbstractClient

MediasDocumentsClient

Table of contents

Properties

Methods

Properties

articles

Readonly articles: MediasDocumentsArticlesClient

Attribute to access all methods concerning articles of medias documents.

Methods

addLinkDocument

addLinkDocument(mediaId, linkBody): Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

Parameters

Name Type Description
mediaId string The uuid of the targeted media link.
linkBody IPublicCreateMediaLinkDocumentParams The body of the media link document.

Returns

Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

Promise object representing the media link document added, the requestId.

Summary

Add document to existing link media.

Example

const linkParams : IPublicCreateMediaLinkDocumentParams = {
     url: "www.test.com",
     lang: "en",
};
const linkDocument = await client.medias.documents.addLinkDocument("media_id", linkParams);

addMediaDocument

addMediaDocument(mediaId, formData, lang): Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
formData IFormData The form data containing the file to upload.
lang string The lang of the media document.

Returns

Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

Promise object representing the media document uploaded, the requestId.

Summary

Add document to an existing media.

Example

const file = typeof input === 'string' ? fs.createReadStream(input) : input;
const formData = new FormData(); // https://www.npmjs.com/package/form-data
formData.append('file', file);
const mediaDocumentUploaded = await client.medias.documents.addMediaDocument("media_id", formData, "en");

changeLang

changeLang(mediaId, documentId, lang): Promise<void>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.
lang string The new lang

Returns

Promise<void>

Summary

Change lang of a document.

Example

await client.medias.documents.changeLang("media_id", "document_id", 'es');

changeMediaDocumentThumb

changeMediaDocumentThumb(mediaId, documentId, formData): Promise<IPublicMediaDocumentThumbUpdateResultDataWithRequestId>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.
formData IFormData The form data containing the file to upload.

Returns

Promise<IPublicMediaDocumentThumbUpdateResultDataWithRequestId>

Promise object representing information concerning the media document for which the thumb has been modified, the requestId and diagnoses of the operation.

Summary

Change the thumb of the specified media document.

Example

const file = typeof input === 'string' ? fs.createReadStream(input) : input;
const formData = new FormData(); // https://www.npmjs.com/package/form-data
formData.append('file', file);
const result = await client.medias.documents.changeMediaDocumentThumb("media_id", "document_id", formData);

deleteMediaDocument

deleteMediaDocument(mediaId, documentId): Promise<void>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.

Returns

Promise<void>

Summary

Delete a media document (only when the media has more than one document).

Example

await client.medias.documents.deleteMediaDocument("media_id", "document_id");

deleteZZO

deleteZZO(mediaId, documentId): Promise<IPublicDeleteZZOResult>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.

Returns

Promise<IPublicDeleteZZOResult>

Promise object representing the requestId.

Summary

Delete all ZZO for a document from source pdf.

Example

const result = await client.medias.documents.deleteZZO("media_id", "document_id");

detectZZO

detectZZO(mediaId, documentId): Promise<IPublicDetectZZOResult>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.

Returns

Promise<IPublicDetectZZOResult>

Promise object representing the requestId.

Summary

Create ZZO for a document from source pdf.

Example

const result = await client.medias.documents.detectZZO("media_id", "document_id");

downloadMediaDocumentThumb

downloadMediaDocumentThumb(mediaId, documentId, height?, animated?): Promise<IUbstreamHttpResponseStream>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.
height? number The height of the thumb. By default, the height is the original thumb height.
animated? boolean -

Returns

Promise<IUbstreamHttpResponseStream>

Promise object representing a readable stream, the content-type and the name of the downloaded thumb.

Summary

Download the thumb of the specified media document.

Example

const response = await client.medias.documents.downloadMediaDocumentThumb(
  "media_id",
  "document_id",
  1000
);
// Use the readable stream to retrieve the thumb.
const writer = fs.createWriteStream(`./${response.filename}`);
await new Promise(((resolve, reject) => {
  writer.on('error', (e) => {
      reject(e);
  })
  writer.on('close', () => {
      resolve(undefined);
  })
  response.stream.pipe(writer);
}));

getMediaDocumentFullText

getMediaDocumentFullText(mediaId, documentId): Promise<IPublicMediaDocumentTextContent>

Parameters

Name Type Description
mediaId string The uuid of the targeted media.
documentId string The uuid of the targeted document.

Returns

Promise<IPublicMediaDocumentTextContent>

Promise object containing the full text of the document.

Summary

Get full text of a document.

Example

const result = await client.medias.documents.getMediaDocumentFullText("media_id", "document_id");

listMediaDocuments

listMediaDocuments(mediaId, revision?): Promise<IPublicMediaDocumentQuery>

Parameters

Name Type Default value Description
mediaId string undefined The uuid of the targeted media.
revision PublicMediaDocumentRevision PublicMediaDocumentRevision.PUBLISHED The choice of the revision.
  • "wip" will get only document with wip revision. This is the default parameter.
  • "published" will get only document with published revision. This is the default parameter.
  • Returns

    Promise<IPublicMediaDocumentQuery>

    Promise object representing media's documents.

    Summary

    Retrieve media's documents.

    Example

    const result = await client.medias.documents.listMediaDocuments("media_id");
    const documents = result.$resources;
    

    updateLinkDocument

    updateLinkDocument(mediaId, documentId, updateBody): Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

    Parameters

    Name Type Description
    mediaId string The uuid of the targeted media.
    documentId string The uuid of the targeted document.
    updateBody IPublicUpdateMediaLinkParams The new body of the link

    Returns

    Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

    Promise object representing the link document added, the requestId.

    Summary

    Update a link document.

    Example

    const updateLinkParams : IPublicUpdateMediaLinkParams {
        url: "ubstream.com",
    };
    const updatedLinkDocument = await client.medias.documents.updateLinkDocument("media_id", "document_id", updateLinkParams);
    

    updateMediaDocument

    updateMediaDocument(mediaId, documentId, formData): Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

    Parameters

    Name Type Description
    mediaId string The uuid of the targeted media.
    documentId string The uuid of the target document.
    formData IFormData The form data containing the file to upload.

    Returns

    Promise<IPublicMediaDocumentUploadResultDataWithRequestId>

    Promise object representing the media document uploaded, the requestId.

    Summary

    Update a media document.

    Example

    const file = typeof input === 'string' ? fs.createReadStream(input) : input;
    const formData = new FormData(); // https://www.npmjs.com/package/form-data
    formData.append('file', file);
    const updatedMediaDocument = await client.medias.documents.updateMediaDocument("media_id", "document_id", formData);