-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Shumkin
authored and
Alexander Shumkin
committed
Jul 29, 2022
1 parent
5574b79
commit d9459e8
Showing
14 changed files
with
152 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
AspNetCore.Yandex.ObjectStorage/Bucket/Builders/BucketMetaRequestBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Net.Http; | ||
using AspNetCore.Yandex.ObjectStorage.Bucket.Requests; | ||
using AspNetCore.Yandex.ObjectStorage.Configuration; | ||
using AspNetCore.Yandex.ObjectStorage.Helpers; | ||
|
||
namespace AspNetCore.Yandex.ObjectStorage.Bucket.Builders | ||
{ | ||
internal class BucketMetaRequestBuilder | ||
{ | ||
private readonly YandexStorageOptions _options; | ||
private HttpRequestMessage _request; | ||
|
||
internal BucketMetaRequestBuilder(YandexStorageOptions options) | ||
{ | ||
_options = options; | ||
} | ||
|
||
internal BucketMetaRequestBuilder Build(string bucketName) | ||
{ | ||
var url = $"{_options.Protocol}://{_options.Endpoint}/{bucketName}"; | ||
|
||
var requestMessage = new HttpRequestMessage(HttpMethod.Head, new Uri(url)); | ||
var dateAmz = DateTime.UtcNow; | ||
|
||
requestMessage.AddBothHeaders(_options, dateAmz); | ||
|
||
string[] headers = { "host", "x-amz-content-sha256", "x-amz-date" }; | ||
requestMessage.AddAuthHeader(_options, dateAmz, headers); | ||
_request = requestMessage; | ||
|
||
return this; | ||
} | ||
|
||
internal HttpRequestMessage GetResult() | ||
{ | ||
return _request; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using FluentResults; | ||
|
||
namespace AspNetCore.Yandex.ObjectStorage.Models | ||
{ | ||
public class S3Response : BaseS3Response | ||
{ | ||
public S3Response(HttpResponseMessage response) : base(response) | ||
{ | ||
} | ||
|
||
public async Task<Result<string>> ReadResultAsStringAsync() | ||
{ | ||
if (IsSuccessStatusCode) | ||
{ | ||
return await Response.Content.ReadAsStringAsync(); | ||
} | ||
|
||
return Result.Fail(await Response.Content.ReadAsStringAsync()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
....ObjectStorage/Models/S3DeleteResponse.cs → ...e/Object/Models/S3ObjectDeleteResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...dex.ObjectStorage/Models/S3GetResponse.cs → ...rage/Object/Models/S3ObjectGetResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...dex.ObjectStorage/Models/S3PutResponse.cs → ...rage/Object/Models/S3ObjectPutResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.