open source – How to Upload a Zip File and Create an AppBundle in Autodesk Forge Design Automation SDK?
I am trying to upload a zip file to Autodesk Forge’s Object Storage Service (OSS) and then use it to create an AppBundle for Design Automation. While I successfully upload the file and create the AppBundle, the package URL linked to the AppBundle always gives a NoSuchKey error when accessed.
Here’s the relevant part of my code:
var auth = new TwoLeggedApi();
dynamic tokenResponse = await auth.AuthenticateAsync(
ClientId,
ClientSecret,
oAuthConstants.CLIENT_CREDENTIALS,
[Scope.DataRead, Scope.DataWrite]
);
var objectsApi = new ObjectsApi { Configuration = { AccessToken = tokenResponse.access_token; } };
using var fileStream = new FileStream(zipFilePath, FileMode.Open, FileAccess.Read);
dynamic response = await objectsApi.UploadObjectAsync(
bucketKey,
objectKey,
(int)fileStream.Length,
fileStream,
"application/zip"
);
string ossObjectUrl = $"https://developer.api.autodesk.com/oss/v2/buckets/{bucketKey}/objects/{objectKey}";
string fullyQualifiedId = $"{_account}.{bundleId}";
var newVersion = new AppBundle
{
Id = fullyQualifiedId,
Engine = $"Autodesk.Revit+{yearVersion}",
Package = ossObjectUrl,
Description = $"App bundle for Revit {yearVersion}",
};
AppBundle bundle = await _daClient.CreateAppBundleAsync(newVersion);
// package URL is valid
// after creating an alias and fetching the AppBundle again, the package url is invalid
The AppBundle is created successfully, but when I set an alias and try to access the package URL, I get an error:
NoSuchKey
The specified key does not exist.
Read more here: Source link