UNPKG

forge-oss

Version:

Asynchronous Javascript/Node.js library for the Autodesk Forge OSS API.

526 lines (482 loc) 32.4 kB
/* * The MIT License (MIT) * * Copyright (c) 2016 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * */ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['ApiClient', 'model/Reason', 'model/ObjectDetails', 'model/PostObjectSigned', 'model/PostBucketsSigned', 'model/InputStream', 'model/ObjectFullDetails', 'model/InlineResponse2001'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('../model/Reason'), require('../model/ObjectDetails'), require('../model/PostObjectSigned'), require('../model/PostBucketsSigned'), require('../model/InputStream'), require('../model/ObjectFullDetails'), require('../model/InlineResponse2001')); } else { // Browser globals (root is window) if (!root.ForgeOss) { root.ForgeOss = {}; } root.ForgeOss.ObjectsApi = factory(root.ForgeOss.ApiClient, root.ForgeOss.Reason, root.ForgeOss.ObjectDetails, root.ForgeOss.PostObjectSigned, root.ForgeOss.PostBucketsSigned, root.ForgeOss.InputStream, root.ForgeOss.ObjectFullDetails, root.ForgeOss.InlineResponse2001); } }(this, function(ApiClient, Reason, ObjectDetails, PostObjectSigned, PostBucketsSigned, InputStream, ObjectFullDetails, InlineResponse2001) { 'use strict'; /** * Objects service. * @module api/ObjectsApi */ /** * Constructs a new ObjectsApi. * @alias module:api/ObjectsApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ var ForgeSDK = require('forge-apis'); var exports = function(apiClient) { this.apiClient = apiClient || ApiClient.instance; this.mdClient = new ForgeSDK.ObjectsApi(); this.oauth2_application = new ForgeSDK.AuthClientTwoLegged('1234', '1234', ['data:read'], false); /** * Callback function to receive the result of the copyTo operation. * @callback module:api/ObjectsApi~copyToCallback * @param {String} error Error message, if any. * @param {module:model/ObjectDetails} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Copies an object to another object name in the same bucket. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {String} newObjName URL-encoded Object key to use as the destination * @param {module:api/ObjectsApi~copyToCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ObjectDetails} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ObjectDetails} */ this.copyToEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}/copyTo/{newObjName}' ; this.copyTo = function(bucketKey, objectName, newObjName, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.copyTo(bucketKey, objectName, newObjName, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the createSignedResource operation. * @callback module:api/ObjectsApi~createSignedResourceCallback * @param {String} error Error message, if any. * @param {module:model/PostObjectSigned} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * This endpoint creates a signed URL that can be used to download an object within the specified expiration time. Be aware that if the object the signed URL points to is deleted or expires before the signed URL expires, then the signed URL will no longer be valid. A successful call to this endpoint requires bucket owner access. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {module:model/PostBucketsSigned} postBucketsSigned Body Structure * @param {Object} opts Optional parameters * @param {module:model/String} opts.access Access for signed resource Acceptable values: `read`, `write`, `readwrite`. Default value: `read` (default to read) * @param {module:api/ObjectsApi~createSignedResourceCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/PostObjectSigned} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/PostObjectSigned} */ this.createSignedResourceEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}/signed' ; this.createSignedResource = function(bucketKey, objectName, postBucketsSigned, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.createSignedResource(bucketKey, objectName, postBucketsSigned, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the deleteObject operation. * @callback module:api/ObjectsApi~deleteObjectCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Deletes an object from the bucket. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {module:api/ObjectsApi~deleteObjectCallback} callback The callback function, accepting three arguments: error, data, response * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteObjectEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}' ; this.deleteObject = function(bucketKey, objectName, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.deleteObject(bucketKey, objectName, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the deleteSignedResource operation. * @callback module:api/ObjectsApi~deleteSignedResourceCallback * @param {String} error Error message, if any. * @param {module:model/InputStream} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Delete a signed URL. A successful call to this endpoint requires bucket owner access. * @param {String} id Id of signed resource * @param {Object} opts Optional parameters * @param {module:model/String} opts.region The region where the bucket resides Acceptable values: `US`, `EMEA` Default is `US` (default to US) * @param {module:api/ObjectsApi~deleteSignedResourceCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InputStream} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InputStream} */ this.deleteSignedResourceEndPoint ='/oss/v2/signedresources/{id}' ; this.deleteSignedResource = function(id, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.deleteSignedResource(id, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the getObject operation. * @callback module:api/ObjectsApi~getObjectCallback * @param {String} error Error message, if any. * @param {module:model/InputStream} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Download an object. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {Object} opts Optional parameters * @param {String} opts.range A range of bytes to download from the specified object. * @param {String} opts.ifNoneMatch The value of this header is compared to the ETAG of the object. If they match, the body will not be included in the response. Only the object information will be included. * @param {Date} opts.ifModifiedSince If the requested object has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message body. * @param {String} opts.acceptEncoding When gzip is specified, a gzip compressed stream of the object’s bytes will be returned in the response. Cannot use “Accept-Encoding:gzip” with Range header containing an end byte range. End byte range will not be honored if “Accept-Encoding: gzip” header is used. * @param {module:api/ObjectsApi~getObjectCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InputStream} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InputStream} */ this.getObjectEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}' ; this.getObject = function(bucketKey, objectName, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.getObject(bucketKey, objectName, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the getObjectDetails operation. * @callback module:api/ObjectsApi~getObjectDetailsCallback * @param {String} error Error message, if any. * @param {module:model/ObjectFullDetails} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Returns object details in JSON format. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {Object} opts Optional parameters * @param {Date} opts.ifModifiedSince If the requested object has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message body. * @param {module:model/String} opts._with Extra information in details; multiple uses are supported Acceptable values: `createdDate`, `lastAccessedDate`, `lastModifiedDate` * @param {module:api/ObjectsApi~getObjectDetailsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ObjectFullDetails} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ObjectFullDetails} */ this.getObjectDetailsEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}/details' ; this.getObjectDetails = function(bucketKey, objectName, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.getObjectDetails(bucketKey, objectName, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the getObjects operation. * @callback module:api/ObjectsApi~getObjectsCallback * @param {String} error Error message, if any. * @param {module:model/InlineResponse2001} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * List objects in a bucket. It is only available to the bucket creator. * @param {String} bucketKey URL-encoded bucket key * @param {Object} opts Optional parameters * @param {Integer} opts.limit Limit to the response size, Acceptable values: 1-100 Default = 10 (default to 10) * @param {String} opts.beginsWith Provides a way to filter the based on object key name * @param {String} opts.startAt Key to use as an offset to continue pagination This is typically the last bucket key found in a preceding GET buckets response * @param {module:api/ObjectsApi~getObjectsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InlineResponse2001} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InlineResponse2001} */ this.getObjectsEndPoint ='/oss/v2/buckets/{bucketKey}/objects' ; this.getObjects = function(bucketKey, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.getObjects(bucketKey, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the getSessionid operation. * @callback module:api/ObjectsApi~getSessionidCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * This endpoint returns status information about a resumable upload. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {String} sessionId Unique identifier of a session of a file being uploaded * @param {module:api/ObjectsApi~getSessionidCallback} callback The callback function, accepting three arguments: error, data, response * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.getSessionidEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}/status/{sessionId}' ; this.getSessionid = function(bucketKey, objectName, sessionId, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.getStatusBySessionId(bucketKey, objectName, sessionId, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the getSignedResource operation. * @callback module:api/ObjectsApi~getSignedResourceCallback * @param {String} error Error message, if any. * @param {module:model/InputStream} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Download an object using a signed URL. * @param {String} id Id of signed resource * @param {Object} opts Optional parameters * @param {String} opts.range A range of bytes to download from the specified object. * @param {String} opts.ifNoneMatch The value of this header is compared to the ETAG of the object. If they match, the body will not be included in the response. Only the object information will be included. * @param {Date} opts.ifModifiedSince If the requested object has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message body. * @param {String} opts.acceptEncoding When gzip is specified, a gzip compressed stream of the object’s bytes will be returned in the response. Cannot use “Accept-Encoding:gzip” with Range header containing an end byte range. End byte range will not be honored if “Accept-Encoding: gzip” header is used. * @param {module:model/String} opts.region The region where the bucket resides Acceptable values: `US`, `EMEA` Default is `US` (default to US) * @param {module:api/ObjectsApi~getSignedResourceCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InputStream} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InputStream} */ this.getSignedResourceEndPoint ='/oss/v2/signedresources/{id}' ; this.getSignedResource = function(id, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.getSignedResource(id, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the uploadChunk operation. * @callback module:api/ObjectsApi~uploadChunkCallback * @param {String} error Error message, if any. * @param {module:model/ObjectDetails} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * This endpoint allows resumable uploads for large files in chunks. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {Integer} contentLength Indicates the size of the request body. * @param {String} contentRange Byte range of a segment being uploaded * @param {String} sessionId Unique identifier of a session of a file being uploaded * @param {module:model/InputStream} body * @param {Object} opts Optional parameters * @param {String} opts.contentDisposition The suggested default filename when downloading this object to a file after it has been uploaded. * @param {String} opts.ifMatch If-Match header containing a SHA-1 hash of the bytes in the request body can be sent by the calling service or client application with the request. If present, OSS will use the value of If-Match header to verify that a SHA-1 calculated for the uploaded bytes server side matches what was sent in the header. If not, the request is failed with a status 412 Precondition Failed and the data is not written. * @param {module:api/ObjectsApi~uploadChunkCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ObjectDetails} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ObjectDetails} */ this.uploadChunkEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}/resumable' ; this.uploadChunk = function(bucketKey, objectName, contentLength, contentRange, sessionId, body, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.uploadChunk(bucketKey, objectName, contentLength, contentRange, sessionId, body, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the uploadObject operation. * @callback module:api/ObjectsApi~uploadObjectCallback * @param {String} error Error message, if any. * @param {module:model/ObjectDetails} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Upload an object. If the specified object name already exists in the bucket, the uploaded content will overwrite the existing content for the bucket name/object name combination. * @param {String} bucketKey URL-encoded bucket key * @param {String} objectName URL-encoded object name * @param {Integer} contentLength Indicates the size of the request body. * @param {module:model/InputStream} body * @param {Object} opts Optional parameters * @param {String} opts.contentDisposition The suggested default filename when downloading this object to a file after it has been uploaded. * @param {String} opts.ifMatch If-Match header containing a SHA-1 hash of the bytes in the request body can be sent by the calling service or client application with the request. If present, OSS will use the value of If-Match header to verify that a SHA-1 calculated for the uploaded bytes server side matches what was sent in the header. If not, the request is failed with a status 412 Precondition Failed and the data is not written. * @param {module:api/ObjectsApi~uploadObjectCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ObjectDetails} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ObjectDetails} */ this.uploadObjectEndPoint ='/oss/v2/buckets/{bucketKey}/objects/{objectName}' ; this.uploadObject = function(bucketKey, objectName, contentLength, body, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.uploadObject(bucketKey, objectName, contentLength, body, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the uploadSignedResource operation. * @callback module:api/ObjectsApi~uploadSignedResourceCallback * @param {String} error Error message, if any. * @param {module:model/PostObjectSigned} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Overwrite a existing object using a signed URL. Conditions to call this operation: Object is available Expiration period is valid Signed URL should be created with `write` or `readwrite` * @param {String} id Id of signed resource * @param {Integer} contentLength Indicates the size of the request body. * @param {module:model/InputStream} body * @param {Object} opts Optional parameters * @param {String} opts.contentDisposition The suggested default filename when downloading this object to a file after it has been uploaded. * @param {module:model/String} opts.xAdsRegion The region where the bucket resides Acceptable values: `US`, `EMEA` Default is `US` (default to US) * @param {String} opts.ifMatch If-Match header containing a SHA-1 hash of the bytes in the request body can be sent by the calling service or client application with the request. If present, OSS will use the value of If-Match header to verify that a SHA-1 calculated for the uploaded bytes server side matches what was sent in the header. If not, the request is failed with a status 412 Precondition Failed and the data is not written. * @param {module:api/ObjectsApi~uploadSignedResourceCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/PostObjectSigned} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/PostObjectSigned} */ this.uploadSignedResourceEndPoint ='/oss/v2/signedresources/{id}' ; this.uploadSignedResource = function(id, contentLength, body, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.uploadSignedResource(id, contentLength, body, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; /** * Callback function to receive the result of the uploadSignedResourcesChunk operation. * @callback module:api/ObjectsApi~uploadSignedResourcesChunkCallback * @param {String} error Error message, if any. * @param {module:model/PostObjectSigned} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Resumable upload for signed URLs. * @param {String} id Id of signed resource * @param {String} contentRange Byte range of a segment being uploaded * @param {String} sessionId Unique identifier of a session of a file being uploaded * @param {module:model/InputStream} body * @param {Object} opts Optional parameters * @param {String} opts.contentDisposition The suggested default filename when downloading this object to a file after it has been uploaded. * @param {module:model/String} opts.xAdsRegion The region where the bucket resides Acceptable values: `US`, `EMEA` Default is `US` (default to US) * @param {module:api/ObjectsApi~uploadSignedResourcesChunkCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/PostObjectSigned} * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/PostObjectSigned} */ this.uploadSignedResourcesChunkEndPoint ='/oss/v2/signedresources/{id}/resumable' ; this.uploadSignedResourcesChunk = function(id, contentRange, sessionId, body, opts, callback) { //this.apiClient.applyToAuthObjects (this.oauth2_access_code, this.oauth2_application, ['oauth2_application']) ; var oauth = this.apiClient.getAuthObject(this.oauth2_access_code, this.oauth2_application, ['oauth2_application']); var pr = this.mdClient.uploadSignedResourcesChunk(id, contentRange, sessionId, body, opts, oauth, oauth.getCredentials()); if (callback === undefined) { return (new Promise(function (resolve, reject) { pr.then(function (result) { resolve(result.body); }) .catch(function (err) { reject(err); }); })) ; } pr.then(function (result) { callback(null, result.body); }) .catch(function (err) { callback(err, null); }); }; }; return exports; }));