How to use the forge-apis.BucketsApi 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
{
        id: '',
        resource: '',
        references: [''],
        requiredEngineVersion: '',
        version: 0,
        description: '',
        isPublic: true,
        isObjectEnabler: true,
    },
    authClientTwoLegged,
    authToken,
);

// $ExpectType BucketsApi
const bucketsApi = new BucketsApi();

// $ExpectType Promise
bucketsApi.createBucket(
    {
        bucketKey: '',
        policyKey: 'transient',
    },
    {},
    authClientTwoLegged,
    authToken,
);
// $ExpectType Promise
bucketsApi.deleteBucket('', authClientTwoLegged, authToken);
// $ExpectType Promise
bucketsApi.getBucketDetails('', authClientTwoLegged, authToken);
// $ExpectType Promise
github Autodesk-Forge / forge-view.googledrive.models / server / model.derivative.google.drive.integration.js View on Github external
if (err || user == null) {
        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;
github cyrillef / extract.autodesk.io / server / forge-token.js View on Github external
var createApplicationBucket =function () {
	// Ok, now it might be the first time we run that sample on this account key-pair
	// and the bucket may not exists yet! so create it now otherwise we will get into trouble later.
	var sdk =new ForgeSDK.BucketsApi () ;
	sdk.getBucketDetails (config.bucket, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials ())
		.then (function (bucket) {
			// We are all good! :)
			console.log (config.bucket, 'present!') ;
		})
		.catch (function (error) {
			console.error (config.bucket, 'does not exist?', error) ;
			if ( error.statusCode === 404 ) {
				console.log ('Creating bucket: ', config.bucket) ;
				sdk.createBucket ({ bucketKey: config.bucket, policyKey: 'persistent' }, {}, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials ())
					.then (function (response) {
						// We are all good now! :)
						console.log (config.bucket, 'created! -') ;
					})
					.catch (function (error) {
						console.error (config.bucket, 'could not be created! - ', error) ;
github Autodesk-Forge / forge.commandline-nodejs / api / oss.js View on Github external
.then((oa2legged) => {
				let ossBuckets = new ForgeAPI.BucketsApi();
				return (ossBuckets.deleteBucket(bucketKey, oa2legged, oa2legged.getCredentials()));
			})
			.then((response) => { // eslint-disable-line no-unused-vars
github Autodesk-Forge / models.autodesk.io / server / lmv-projects.js View on Github external
function ExistOrCreate (bucketKey, oAuth2) {
	console.log ('Check Bucket if bucket exists...') ;
	var ossBuckets =new ForgeApis.BucketsApi () ;
	return (ossBuckets.getBucketDetails (bucketKey, oAuth2, oAuth2.getCredentials ())
		.then (function (results) {
			return (results) ;
		})
		.catch (function (error) {
			console.log ('Create Bucket...') ;
			var opts ={
				bucketKey: bucketKey,
				policyKey: 'persistent'
			} ;
			var headers ={
				xAdsRegion: 'US'
			} ;
			return (ossBuckets.createBucket (opts, headers, oAuth2, oAuth2.getCredentials ())) ;
		})
	) ;
github Autodesk-Forge / forge-boilers.nodejs / 6 - viewer+server+data-mng+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-rcdb.nodejs / 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 ossBuckets = new ForgeAPI.BucketsApi();
				let opts = {
					bucketKey: bucketKey,
					policyKey: type
				};
				if (authid && access)
					opts.allow = { authid: authid, access: access };
				let headers = {
					'xAdsRegion': region
				};
				return (ossBuckets.createBucket(opts, headers, oa2legged, oa2legged.getCredentials()));
			})
			.then((bucket) => {
github Autodesk-Forge / forge.commandline-nodejs / api / oss.js View on Github external
.then((oa2legged) => {
				let ossBuckets = new ForgeAPI.BucketsApi();
				return (ossBuckets.getBuckets(opts, oa2legged, oa2legged.getCredentials()));
			})
			.then((buckets) => {