Skip to content

Support NativeAOT #58

@ivanjx

Description

@ivanjx
  • I hereby verify that I am a sponsor.

Description of the bug
PutObject works fine under NativeAOT but when i tried to get the file back with GetObject it gives me an empty stream instead. I manually verified that the PutObject works fine on both normal and AOT mode by downloading and checking the file myself.

How to reproduce?

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishAot>true</PublishAot>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Genbox.SimpleS3.AmazonS3" Version="3.0.0" />
  </ItemGroup>

</Project>
using System.Text;
using Genbox.SimpleS3.AmazonS3;
using Genbox.SimpleS3.Core.Abstracts.Enums;
using Genbox.SimpleS3.Core.Common.Authentication;
using Genbox.SimpleS3.Core.Extensions;
using Genbox.SimpleS3.Core.Network.Responses.Objects;
using Genbox.SimpleS3.Extensions.AmazonS3;

AmazonS3Config config = new AmazonS3Config();
config.EndpointTemplate = "{Scheme}://play.min.io/{Bucket}";
config.Region = AmazonS3Region.UsEast1;
config.Credentials = new StringAccessKey("1nM2dy8VWatJ7EJ4nEBg", "CPeDvsHZA12kvcMXc6GJzdb6bIKo5FScCsYKKdgL");
config.NamingMode = NamingMode.PathStyle;

using AmazonS3Client client = new AmazonS3Client(config);
using MemoryStream dataStream = new MemoryStream(
    Encoding.ASCII.GetBytes("Hello World!! + " + DateTime.UtcNow.ToString("o")));
PutObjectResponse resp = await client.PutObjectAsync(
    "testbucket",
    "objectname22",
    dataStream);

GetObjectResponse resp2 = await client.GetObjectAsync("testbucket", "objectname22");
using StreamReader reader = new StreamReader(resp2.Content);
Console.WriteLine("Content: [{0}]", await reader.ReadToEndAsync());


Console.WriteLine("Success: " + resp.IsSuccess);

compile with: dotnet publish -c Release

normal output:

Content: [Hello World!! + 2023-08-05T04:00:19.6423971Z]
Success: True

NativeAOT output:

Content: []
Success: True

Expected behavior
GetObject's Content has data in it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions