The Autodesk Platform Services (APS) SDK for .NET helps .NET developer create applications that leverage the various APS services: Model Derivative, Data Management, OSS, Webhooks. More services soon.
Buckets are virtual container within the Object Storage Service (OSS), which you can use to store and manage objects (files) in the cloud.
First, you need to install the package aps-sdk-net library :
<PackageReference Include="Autodesk.Oss" Version="2.0.0" />
Create a Bucket
So now you can use some code like this to create an bucket:
using Autodesk.Oss.Model;
using Autodesk.SDKManager;
var sdkManager = SdkManagerBuilder
.Create()
.Add(new ApsConfiguration())
.Add(ResiliencyConfiguration.CreateDefault())
.Build();
var _ossClient = new OssClient(sdkManager);
Bucket bucket = await _ossClient.CreateBucketAsync(
accessToken: token,
xAdsRegion: Region.US,
bucketsPayload: new CreateBucketsPayload()
{
BucketKey = bucketKey,
PolicyKey = PolicyKey.Temporary
});
Get Bucket Details
Bucket bucket = await _ossClient.GetBucketDetailsAsync(
accessToken: token,
bucketKey: bucketKey);
Get Bucket :
Buckets buckets = await _ossClient.GetBucketsAsync(accessToken: token);
Delete Bucket
HttpResponseMessage httpResponseMessage = await _ossClient.DeleteBucketAsync(
accessToken: token,
bucketKey: bucketKey);
Upload an object to bucket
ObjectDetails objectDetails = await _ossClient.UploadObjectAsync(
accessToken: token,
bucketKey: bucketKey,
objectKey: objectKey,
sourceToUpload: sourceToUpload,
cancellationToken: CancellationToken.None);
Copy object from bucket
ObjectDetails objectDetails = await _ossClient.CopyToAsync(
accessToken: token,
bucketKey: bucketKey,
objectKey: objectKey,
newObjName: newObjName);
Download Bucket Object
await _ossClient.DownloadObjectAsync(
accessToken: token,
bucketKey: bucketKey,
objectKey: objectKey,
filePath: filePath,
cancellationToken: CancellationToken.None);
Get Object Info
BucketObjects bucketObjects = await _ossClient.GetObjectsAsync(
accessToken: token,
bucketKey: bucketKey);
Detele Object Info
HttpResponseMessage httpResponseMessage = await _ossClient.DeleteObjectAsync(
accessToken: token,
bucketKey: bucketKey,
objectKey: objectKey);
Top comments (1)
Test