From 94f9b64bbd351689b805817cb0e0c9a950c7f5fa Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Wed, 29 Jun 2022 16:12:39 -0700 Subject: [PATCH 1/3] gh-18 Use synchronous call to copy stream in GetObject* calls Signed-off-by: Victor Chang --- src/Plugins/MinIO/MinIoStorageService.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Plugins/MinIO/MinIoStorageService.cs b/src/Plugins/MinIO/MinIoStorageService.cs index 5aca265..3903b75 100644 --- a/src/Plugins/MinIO/MinIoStorageService.cs +++ b/src/Plugins/MinIO/MinIoStorageService.cs @@ -67,11 +67,9 @@ public async Task GetObjectAsync(string bucketName, string objectName, C Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); - var stream = new MemoryStream(); - var client = _minioClientFactory.GetClient(); - await GetObjectUsingClient(client, bucketName, objectName, async (s) => await s.CopyToAsync(stream), cancellationToken).ConfigureAwait(false); - + var stream = new MemoryStream(); + await GetObjectUsingClient(client, bucketName, objectName, (s) => s.CopyTo(stream), cancellationToken).ConfigureAwait(false); return stream; } @@ -219,12 +217,9 @@ public async Task GetObjectWithCredentialsAsync(string bucketName, strin Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); - var stream = new MemoryStream(); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); - - await GetObjectUsingClient(client, bucketName, objectName, async (s) => await s.CopyToAsync(stream), cancellationToken).ConfigureAwait(false); - + var stream = new MemoryStream(); + await GetObjectUsingClient(client, bucketName, objectName, (s) => s.CopyTo(stream), cancellationToken).ConfigureAwait(false); return stream; } From 19185b262eeabe7a463b4f9e232e45008f98478e Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Wed, 29 Jun 2022 16:27:15 -0700 Subject: [PATCH 2/3] Include artifacts in release Signed-off-by: Victor Chang --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26625ee..099300b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -234,6 +234,32 @@ jobs: name: Publish to GitHub Packages runs-on: ubuntu-latest needs: [build, unit-test] + if: ${{ ! ( github.event.inputs.nuget ) }} + steps: + - uses: actions/download-artifact@v2 + id: download + + - name: List artifacts + run: ls -ldR ${{steps.download.outputs.download-path}}/**/* + + - name: Install grp + run: dotnet tool install gpr -g + + - uses: actions/setup-dotnet@v1 + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + dotnet-version: "6.0.x" + source-url: https://nuget.pkg.github.com/Project-MONAI/index.json + + - name: Publish to GitHub + run: gpr push '${{ steps.download.outputs.download-path }}/nuget/*.nupkg' --repository ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }} + + release-nuget: + name: Official Release to GitHub Packages + runs-on: ubuntu-latest + needs: [build, unit-test] + if: ${{ github.event.inputs.nuget }} steps: - uses: actions/download-artifact@v2 id: download @@ -296,6 +322,8 @@ jobs: repository: ${{ steps.repo.outputs._1 }} milestone: ${{ env.MAJORMINORPATCH }} name: Release v${{ env.MAJORMINORPATCH }} + assets: | + ${{ steps.download.outputs.download-path }}/plug-ins/*.zip - name: Publish release with GitReleaseManager if: ${{ contains(github.ref, 'refs/heads/main') }} From eda7afc1565b20d494a3fdb625ada8e8c39e6ff7 Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Wed, 29 Jun 2022 17:05:38 -0700 Subject: [PATCH 3/3] Set position to the beginning before returning the stream Signed-off-by: Victor Chang --- src/Plugins/MinIO/MinIoStorageService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Plugins/MinIO/MinIoStorageService.cs b/src/Plugins/MinIO/MinIoStorageService.cs index 3903b75..b423b1d 100644 --- a/src/Plugins/MinIO/MinIoStorageService.cs +++ b/src/Plugins/MinIO/MinIoStorageService.cs @@ -70,6 +70,7 @@ public async Task GetObjectAsync(string bucketName, string objectName, C var client = _minioClientFactory.GetClient(); var stream = new MemoryStream(); await GetObjectUsingClient(client, bucketName, objectName, (s) => s.CopyTo(stream), cancellationToken).ConfigureAwait(false); + stream.Seek(0, SeekOrigin.Begin); return stream; } @@ -220,6 +221,7 @@ public async Task GetObjectWithCredentialsAsync(string bucketName, strin var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); var stream = new MemoryStream(); await GetObjectUsingClient(client, bucketName, objectName, (s) => s.CopyTo(stream), cancellationToken).ConfigureAwait(false); + stream.Seek(0, SeekOrigin.Begin); return stream; }