async CreateProductionMaster({
    libraryId,
    name,
    description,
    metadata={},
    fileInfo,
    access,
    filePaths=[],
    copy=false,
    callback
  }) {
    const contentType = await this.ContentType({name: "Production Master"});

    if(!contentType) {
      throw "Unable to access content type 'Production Master' to create production master";
    }

    const {id, write_token} = await this.CreateContentObject({
      libraryId,
      options: {
        type: contentType.hash
      }
    });

    let accessParameter;
    if(access) {
      // S3 Upload
      const {region, bucket, accessKey, secret} = access;

      await this.UploadFilesFromS3({
        libraryId,
        objectId: id,
        writeToken: write_token,
        filePaths,
        region,
        bucket,
        accessKey,
        secret,
        copy,
        callback
      });

      accessParameter = [
        {
          path_matchers: [".*"],
          remote_access: {
            protocol: "s3",
            platform: "aws",
            path: bucket + "/",
            storage_endpoint: {
              region
            },
            cloud_credentials: {
              access_key_id: accessKey,
              secret_access_key: secret
            }
          }
        }
      ];
    } else {
      await this.UploadFiles({
        libraryId,
        objectId: id,
        writeToken: write_token,
        fileInfo,
        callback
      });
    }

    const { logs, errors, warnings } = await this.CallBitcodeMethod({
      libraryId,
      objectId: id,
      writeToken: write_token,
      method: UrlJoin("media", "production_master", "init"),
      body: {
        access: accessParameter
      },
      constant: false
    });

    await this.MergeMetadata({
      libraryId,
      objectId: id,
      writeToken: write_token,
      metadata: {
        name,
        description,
        reference: access && !copy,
        public: {
          name: name || "",
          description: description || ""
        },
        elv_created_at: new Date().getTime(),
        ...(metadata || {})
      }
    });

    const finalizeResponse = await this.FinalizeContentObject({
      libraryId,
      objectId: id,
      writeToken: write_token,
      awaitCommitConfirmation: false
    });

    return {
      errors: errors || [],
      logs: logs || [],
      warnings: warnings || [],
      ...finalizeResponse
    };
  }
/**
   * Create a master media content object with the given files.
   *
   * - If uploading using local files, use fileInfo parameter (see UploadFiles for format)
   * - If uploading from S3 bucket, use access, filePath and copy, parameters (see UploadFilesFromS3 method)
   *
   * @methodGroup Media
   * @namedParams
   * @param {string} libraryId - ID of the library
   * @param {string} name - Name of the content
   * @param {string=} description - Description of the content
   * @param {string} contentTypeName - Name of the content type to use
   * @param {Object=} metadata - Additional metadata for the content object
   * @param {Object=} fileInfo - (Local) Files to upload to (See UploadFiles method)
   * @param {Array<string>} filePaths - (S3) List of files to copy/reference from bucket
   * @param {boolean=} copy=false - (S3) If specified, files will be copied from S3
   * @param {function=} callback - Progress callback for file upload (See UploadFiles or UploadFilesFromS3 method)
   * @param {Object=} access - (S3) Region, bucket, access key and secret for S3
   * - Format: {region, bucket, accessKey, secret}
   *
   * @throws {Object} error - If the initialization of the master fails, error details can be found in error.body
   * @return {Object} - The finalize response for the object, as well as logs, warnings and errors from the master initialization
   */
Create a master media content object with the given files.
- If uploading using local files, use fileInfo parameter
- If uploading from S3 bucket, use access, filePath and copy, parameters



@throws {Object} error - If the initialization of the master fails, error details can be found in error.body
@return {Object} - The finalize response for the object, as well as logs, warnings and errors from the master initialization
Create a master media content object with the given files . - If uploading using local files use fileInfo parameter - If uploading from S3 bucket use access filePath and copy parameters @throws { Object } error - If the initialization of the master fails error details can be found in error . body @return { Object } - The finalize response for the object as well as logs warnings and errors from the master initialization
async CreateProductionMaster({
    libraryId,
    name,
    description,
    metadata={},
    fileInfo,
    access,
    filePaths=[],
    copy=false,
    callback
  }) {
    const contentType = await this.ContentType({name: "Production Master"});
    if(!contentType) {
      throw "Unable to access content type 'Production Master' to create production master";
    }
    const {id, write_token} = await this.CreateContentObject({
      libraryId,
      options: {
        type: contentType.hash
      }
    });
    let accessParameter;
    if(access) {
      const {region, bucket, accessKey, secret} = access;
      await this.UploadFilesFromS3({
        libraryId,
        objectId: id,
        writeToken: write_token,
        filePaths,
        region,
        bucket,
        accessKey,
        secret,
        copy,
        callback
      });
      accessParameter = [
        {
          path_matchers: [".*"],
          remote_access: {
            protocol: "s3",
            platform: "aws",
            path: bucket + "/",
            storage_endpoint: {
              region
            },
            cloud_credentials: {
              access_key_id: accessKey,
              secret_access_key: secret
            }
          }
        }
      ];
    } else {
      await this.UploadFiles({
        libraryId,
        objectId: id,
        writeToken: write_token,
        fileInfo,
        callback
      });
    }
    const { logs, errors, warnings } = await this.CallBitcodeMethod({
      libraryId,
      objectId: id,
      writeToken: write_token,
      method: UrlJoin("media", "production_master", "init"),
      body: {
        access: accessParameter
      },
      constant: false
    });
    await this.MergeMetadata({
      libraryId,
      objectId: id,
      writeToken: write_token,
      metadata: {
        name,
        description,
        reference: access && !copy,
        public: {
          name: name || "",
          description: description || ""
        },
        elv_created_at: new Date().getTime(),
        ...(metadata || {})
      }
    });
    const finalizeResponse = await this.FinalizeContentObject({
      libraryId,
      objectId: id,
      writeToken: write_token,
      awaitCommitConfirmation: false
    });
    return {
      errors: errors || [],
      logs: logs || [],
      warnings: warnings || [],
      ...finalizeResponse
    };
  }
async CreateProductionMaster ( { libraryId , name , description , metadata = { } , fileInfo , access , filePaths = [ ] , copy = false , callback } ) { const contentType = await this . ContentType ( { name : "Production Master" } ) ; if ( ! contentType ) { throw "Unable to access content type 'Production Master' to create production master" ; } const { id , write_token } = await this . CreateContentObject ( { libraryId , options : { type : contentType . hash } } ) ; let accessParameter ; if ( access ) { const { region , bucket , accessKey , secret } = access ; await this . UploadFilesFromS3 ( { libraryId , objectId : id , writeToken : write_token , filePaths , region , bucket , accessKey , secret , copy , callback } ) ; accessParameter = [ { path_matchers : [ ".*" ] , remote_access : { protocol : "s3" , platform : "aws" , path : bucket + "/" , storage_endpoint : { region } , cloud_credentials : { access_key_id : accessKey , secret_access_key : secret } } } ] ; } else { await this . UploadFiles ( { libraryId , objectId : id , writeToken : write_token , fileInfo , callback } ) ; } const { logs , errors , warnings } = await this . CallBitcodeMethod ( { libraryId , objectId : id , writeToken : write_token , method : UrlJoin ( "media" , "production_master" , "init" ) , body : { access : accessParameter } , constant : false } ) ; await this . MergeMetadata ( { libraryId , objectId : id , writeToken : write_token , metadata : { name , description , reference : access && ! copy , public : { name : name || "" , description : description || "" } , elv_created_at : new Date ( ) . getTime ( ) , ... ( metadata || { } ) } } ) ; const finalizeResponse = await this . FinalizeContentObject ( { libraryId , objectId : id , writeToken : write_token , awaitCommitConfirmation : false } ) ; return { errors : errors || [ ] , logs : logs || [ ] , warnings : warnings || [ ] , ... finalizeResponse } ; }
Create a master media content object with the given files.
Create a master media content object with the given files .
// S3 Upload