Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static IServiceCollection AddS3CloudFiles(this IServiceCollection service
}

serviceCollection.AddSingleton<CloudFilesOptions>(cloudFilesOptions);
serviceCollection.AddTransient<ICloudFilesService, CloudFilesService>();
serviceCollection.AddSingleton<ICloudFilesService, CloudFilesService>();

return serviceCollection;
}
Expand Down
6 changes: 4 additions & 2 deletions SW.CloudFiles.S3/Extensions/CloudFilesOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ namespace SW.CloudFiles.S3;
public static class CloudFilesOptionsExtensions
{
/// <summary>Creates a configured <see cref="AmazonS3Client"/> from the given options.</summary>
public static AmazonS3Client CreateClient(this CloudFilesOptions cloudFilesOptions)
public static AmazonS3Client CreateClient(this S3CloudFilesOptions cloudFilesOptions)
{
var clientConfig = new AmazonS3Config
{
RegionEndpoint = RegionEndpoint.USEast1,
ServiceURL = cloudFilesOptions.ServiceUrl,
UseHttp = new Uri(cloudFilesOptions.ServiceUrl).Scheme.ToLower() == "http",
ForcePathStyle = true
ForcePathStyle = true,
Timeout = TimeSpan.FromSeconds(cloudFilesOptions.TimeoutSeconds),
MaxErrorRetry = cloudFilesOptions.MaxErrorRetry
};

return new AmazonS3Client(cloudFilesOptions.AccessKeyId, cloudFilesOptions.SecretAccessKey, clientConfig);
Expand Down
6 changes: 6 additions & 0 deletions SW.CloudFiles.S3/S3CloudFilesOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ public class S3CloudFilesOptions : CloudFilesOptions
/// Lifecycle rules are: temp1/ (1 day), temp7/ (7 days), temp30/ (30 days), temp365/ (365 days).
/// </summary>
public bool DisableAutoLifecycle { get; set; }

/// <summary>Per-request timeout, in seconds, for the underlying <see cref="Amazon.S3.AmazonS3Client"/>. Defaults to 15.</summary>
public int TimeoutSeconds { get; set; } = 15;

/// <summary>Max automatic retries for the underlying <see cref="Amazon.S3.AmazonS3Client"/>. Defaults to 2.</summary>
public int MaxErrorRetry { get; set; } = 2;
}
2 changes: 1 addition & 1 deletion SW.CloudFiles.S3/Services/CloudFilesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CloudFilesService : IDisposable, ICloudFilesService
public CloudFilesService(CloudFilesOptions cloudFilesOptions)
{
this.cloudFilesOptions = cloudFilesOptions;
client = cloudFilesOptions.CreateClient();
client = ((S3CloudFilesOptions)cloudFilesOptions).CreateClient();
}

/// <inheritdoc/>
Expand Down
Loading