-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7460 from abpframework/maliming/IRemoteStreamContent
Refactor IRemoteStreamContent related functions.
- Loading branch information
Showing
11 changed files
with
150 additions
and
52 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.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
25 changes: 0 additions & 25 deletions
25
...rc/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/InternalRemoteStreamContent.cs
This file was deleted.
Oops, something went wrong.
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
16 changes: 0 additions & 16 deletions
16
...rk/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Content/ReferencedRemoteStreamContent.cs
This file was deleted.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
....Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.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,36 @@ | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Shouldly; | ||
using Volo.Abp.Content; | ||
|
||
namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters | ||
{ | ||
[Route("api/remote-stream-content-test")] | ||
public class RemoteStreamContentTestController : AbpController | ||
{ | ||
[HttpGet] | ||
[Route("Download")] | ||
public async Task<IRemoteStreamContent> DownloadAsync() | ||
{ | ||
var memoryStream = new MemoryStream(); | ||
await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("DownloadAsync")); | ||
|
||
return new RemoteStreamContent(memoryStream) | ||
{ | ||
ContentType = "application/rtf" | ||
}; | ||
} | ||
|
||
[HttpPost] | ||
[Route("Upload")] | ||
public async Task<string> UploadAsync([FromBody]IRemoteStreamContent streamContent) | ||
{ | ||
using (var reader = new StreamReader(streamContent.GetStream())) | ||
{ | ||
return await reader.ReadToEndAsync() + ":" + streamContent.ContentType; | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.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,37 @@ | ||
using System.IO; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters | ||
{ | ||
public class RemoteStreamContentTestController_Tests : AspNetCoreMvcTestBase | ||
{ | ||
[Fact] | ||
public async Task DownloadAsync() | ||
{ | ||
var result = await GetResponseAsync("/api/remote-stream-content-test/download"); | ||
result.Content.Headers.ContentType?.ToString().ShouldBe("application/rtf"); | ||
(await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync"); | ||
} | ||
|
||
[Fact] | ||
public async Task UploadAsync() | ||
{ | ||
using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/api/remote-stream-content-test/upload")) | ||
{ | ||
var memoryStream = new MemoryStream(); | ||
await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("UploadAsync")); | ||
memoryStream.Position = 0; | ||
requestMessage.Content = new StreamContent(memoryStream); | ||
requestMessage.Content.Headers.Add("Content-Type", "application/rtf"); | ||
|
||
var response = await Client.SendAsync(requestMessage); | ||
|
||
(await response.Content.ReadAsStringAsync()).ShouldBe("UploadAsync:application/rtf"); | ||
} | ||
} | ||
} | ||
} |
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