Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Download function in oss sample. #26

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions oss/source/custom-code/OssClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Autodesk.Oss.Model;
using Autodesk.Oss.Client;
using System.Threading;
using System.Threading.Tasks;

namespace Autodesk.Oss
{
Expand All @@ -30,7 +29,7 @@ public async System.Threading.Tasks.Task<ObjectDetails> Upload(string bucketKey,
var apiResponse = new ApiResponse<ObjectDetails>(response, await LocalMarshalling.DeserializeAsync<ObjectDetails>(response.Content));
return apiResponse.Content;
}
public async Task Download(string bucketKey, string objectKey,string filePath,string accessToken,CancellationToken cancellationToken,string projectScope = "",string requestIdPrefix = "",IProgress<int> progress = null)
public async System.Threading.Tasks.Task Download(string bucketKey, string objectKey,string filePath,string accessToken,CancellationToken cancellationToken,string projectScope = "",string requestIdPrefix = "",IProgress<int> progress = null)
{
await this.oSSFileTransfer.Download(bucketKey,objectKey,filePath,accessToken,cancellationToken,projectScope,requestIdPrefix,progress);
}
Expand Down
7 changes: 7 additions & 0 deletions samples/oss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class OSS
string bucketKey = "<bucket key>";
string objectName = "<object name>";
string sourceToUpload = "<path to source file>";
string filePath ="<path to source file>";
OssClient ossClient = null!;


Expand Down Expand Up @@ -44,6 +45,11 @@ public async Task Upload()
string objectKey = objectDetails.ObjectKey;

}
public async Task Download()
{
//The below helper method takes care of the complete Download process, i.e.
await ossClient.Download(bucketKey, objectName, filePath, accessToken: token, CancellationToken.None);
}

public async void Main()
{
Expand All @@ -53,6 +59,7 @@ public async void Main()
// Call respective methods
await GetBucketDetailsAsync();
await Upload();
await Download();
}
}
}