How to use the forge-apis.ObjectsApi function in forge-apis

To help you get started, we’ve selected a few forge-apis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / forge-apis / forge-apis-tests.ts View on Github external
itemsApi.getItemParentFolder('', '', authClientTwoLegged, authToken);
// $ExpectType Promise
itemsApi.getItemRefs('', '', {}, authClientTwoLegged, authToken);
// $ExpectType Promise
itemsApi.getItemRelationshipsRefs('', '', {}, authClientTwoLegged, authToken);
// $ExpectType Promise
itemsApi.getItemTip('', '', authClientTwoLegged, authToken);
// $ExpectType Promise
itemsApi.getItemVersions('', '', {}, authClientTwoLegged, authToken);
// $ExpectType Promise
itemsApi.postItem('', { included: [{ type: '', id: '' }] }, authClientTwoLegged, authToken);
// $ExpectType Promise
itemsApi.postItemRelationshipsRef('', '', {}, authClientTwoLegged, authToken);

// $ExpectType ObjectsApi
const objectsApi = new ObjectsApi();
// $ExpectType Promise
objectsApi.copyTo('', '', '', authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.createSignedResource('', '', { minutesExpiration: 0 }, {}, authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.deleteObject('', '', authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.deleteSignedResource('', '', authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.getObjectDetails('', '', {}, authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.getObject('', '', {}, authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.getObjects('', {}, authClientTwoLegged, authToken);
// $ExpectType Promise
objectsApi.getSignedResource('', {}, authClientTwoLegged, authToken);
github Autodesk-Forge / forge-view.googledrive.models / server / model.derivative.google.drive.integration.js View on Github external
console.log('model.derivative.google.drive.integration:sentToTranslation:google.user.get => ' + err);
        res.status(500).json({error: 'Cannot get Google user information, please try again.'});
        return;
      }

      // ForgeSDK OSS Bucket Name: username + userId (no spaces, lower case)
      // that way we have one bucket for each Google account using this application
      var ossBucketKey = 
          config.credentials.client_id.toLowerCase() + 
          (
            user.names[0].displayName.replace(/\W+/g, '') +
            user.resourceName.split('/')[1]
          ).toLowerCase();

      var buckets = new ForgeSDK.BucketsApi();
      var objects = new ForgeSDK.ObjectsApi();
      var postBuckets = new ForgeSDK.PostBucketsPayload();
      postBuckets.bucketKey = ossBucketKey;
      postBuckets.policyKey = "transient"; // expires in 24h

      buckets.createBucket(postBuckets, {}, null, tokenInternal).catch(function (err) {console.log(err);}).then(function () {
        // need the Google file information to get the name...
        drive.files.get({
          fileId: googleFileId
        }, function (err, fileInfo) {
          var fileName = fileInfo.title;
          var ossObjectName = googleFileId + '.' + re.exec(fileName)[1]; // googleId + fileExtension (required)

          // at this point the bucket exists (either created or already there)
          objects.getObjects(ossBucketKey, {'limit': 100}, null, tokenInternal).then(function (response) {
            var alreadyTranslated = false;
            var objectsInBucket = response.body.items;
github Autodesk-Forge / forge-derivatives-explorer / routes / data.management.js View on Github external
fs.readFile(fileTempPath, function (err, fileData) {
                    // Upload the new file
                    var objects = new forgeSDK.ObjectsApi();
                    objects.uploadObject(bucketKeyObjectName.bucketKey, bucketKeyObjectName.objectName, fileSize, fileData, {}, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
                        .then(function (objectData) {
                            console.log('uploadObject: succeeded');
                            _resolve(objectData.body.objectId);
                        })
                        .catch(function (error) {
                            console.log('uploadObject: failed');
                            _reject(error);
                        });
                });
            })
github cyrillef / extract.autodesk.io / server / forge-token.js View on Github external
var rebuildBucketContent =function () {
	// If we got an error, it probably means the bucket does not yet exists
	// so it has no content to rebuild on this server
	var sdk =new ForgeSDK.ObjectsApi () ;
	var opts ={ limit: 99 } ;
	sdk.getObjects (config.bucket, opts, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials ())
		.then (function (ll) {
			for ( var i =0, nb =ll.body.items.length ; i < nb ; i++ ) {
				var obj =ll.body.items [i] ;
				var identifier =(obj.size.toString () + '-' + obj.objectKey).replace (/[^0-9a-zA-Z_-]/img, '') ; //.replace (/\s/g, '') ;
				utils.writeFile (utils.data (identifier), JSON.stringify (obj))
					.then (function (data) {
						var urn =new Buffer (this.obj.objectId).toString ('base64') ;
						var md =new ForgeSDK.DerivativesApi () ;
						return (md.getManifest (urn, {}, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials ())) ;
					}.bind ({ obj: obj }))
					.then (function (manifest) {
						manifest.body.name =decodeURI (utils.safeBase64decode (manifest.body.urn).replace (/^.*\//, '')) ;
						manifest.body.key =this.identifier ;
						if ( manifest.body.status === 'success' )
github Autodesk-Forge / viewer-navigation.sample / server / forge.js View on Github external
new Token().getTokenInternal((tokenInternal, apiInstance) => {
		let buckets = new ForgeSDK.BucketsApi();
		let objects = new ForgeSDK.ObjectsApi();

		buckets.getBuckets({}, apiInstance, tokenInternal).then(data => {
			let bucket = data.body.items.find(abucket => abucket.bucketKey === myBucketKey);

			if (bucket) {
				objects.getObjects(bucket.bucketKey, null, apiInstance, tokenInternal).then(data => {
					res.status(200).json(
            data.body.items.map(object => {
	return { id: object.objectKey.split('.')[0], label: object.objectKey, urn: toBase64(object.objectId) };
})
          );
				}, err => errHandler(err, res));
			}
		}, err => errHandler(err, res));
	});
});
github Autodesk-Forge / forge.commandline-nodejs / api / oss.js View on Github external
static objectsGet (filename, outputFile, options) {
		let bucketKey = options.bucket || options.parent.bucket || null;
		let key = options.key || options.parent.key || false;
		if (key)
			filename = Forge_OSS.key2filename(filename);
		let oa2legged = null;
		let ossObjects = new ForgeAPI.ObjectsApi();
		let wstream = null;
		Forge_OSS.readBucketKey(bucketKey)
			.then((name) => {
				bucketKey = name;
				console.log('Downloading object from oss: ' + name + ' - ' + filename);
				return (Forge_OSS.oauth.getOauth2Legged());
			})
			.then((_oa2legged) => {
				oa2legged = _oa2legged;
				return (ossObjects.getObjectDetails(bucketKey, filename, {}, oa2legged, oa2legged.getCredentials()));
			})
			.then((info) => {
				let size = info.body.size;
				if (size <= 0)
					throw new Error('Object size is empty!');
				wstream = fs.createWriteStream(outputFile);
github Autodesk-Forge / forge.commandline-nodejs / api / oss.js View on Github external
.then((oa2legged) => {
				let ossObjects = new ForgeAPI.ObjectsApi();
				return (ossObjects.getObjectDetails(bucketKey, filename, {}, oa2legged, oa2legged.getCredentials()));
			})
			.then((info) => {
github Autodesk-Forge / models.autodesk.io / server / lmv-projects.js View on Github external
function singleUpload (bucketKey, filename, total, oAuth2) {
	var objectKey =makeKey (filename) ;
	var readStream =_fs.createReadStream (filename) ;
	var ossObjects =new ForgeApis.ObjectsApi () ;
	return (ossObjects.uploadObject (bucketKey, objectKey, total, readStream, {}, oAuth2, oAuth2.getCredentials ())) ;
}
github Autodesk-Forge / forge-boilers.nodejs / 5 - viewer+server+oss+derivatives / src / server / api / services / OssSvc.js View on Github external
constructor (config) {

    super(config)

    this._bucketsAPI = new Forge.BucketsApi()
    this._objectsAPI = new Forge.ObjectsApi()
  }
github Autodesk-Forge / forge.commandline-nodejs / api / oss.js View on Github external
.then((oa2legged) => {
				let ossObjects = new ForgeAPI.ObjectsApi();
				return (ossObjects.getObjects(bucketKey, opts, oa2legged, oa2legged.getCredentials()));
			})
			.then((info) => {