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
... | |
.UseKestrel(options => | |
{ | |
options.Limits.MaxRequestBodySize = 209715200; | |
}); | |
... |
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
[HttpPut("upload")] | |
[DisableRequestSizeLimit] //or [RequestFormLimits(MultipartBodyLengthLimit = 629145600)] | |
[RequestSizeLimit(209715200)] | |
public async Task Upload([FromQuery] Guid? messageId) | |
{ | |
... |
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
[HttpPut("upload")] | |
[DisableRequestSizeLimit] //or [RequestFormLimits(MultipartBodyLengthLimit = 629145600)] | |
public async Task Upload([FromQuery] Guid? messageId) | |
{ | |
... |
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
<system.webServer> | |
<security> | |
<requestFiltering> | |
<requestLimits maxAllowedContentLength="209715200" /> | |
</requestFiltering> | |
</security> | |
</system.webServer> |
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
using Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.IO; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading; | |
using System.Threading.Tasks; |
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
// Source: https://forums.xamarin.com/discussion/180009/how-to-work-with-custom-progressable-stream-content | |
using System; | |
using System.IO; | |
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
namespace Misc | |
{ |
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
using Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.IO; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading; | |
using System.Threading.Tasks; |
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
var storageAccount = CloudStorageAccount.Parse(_configuration["MicrosoftAzureStorage:AzureStorageConnectionString"]); | |
var backOffPeriod = TimeSpan.FromSeconds(2); | |
var blobClient = storageAccount.CreateCloudBlobClient(); | |
blobClient.DefaultRequestOptions = new BlobRequestOptions() | |
{ | |
SingleBlobUploadThresholdInBytes = 1024 * 1024, //1MB, the minimum | |
ParallelOperationThreadCount = 1, | |
RetryPolicy = new ExponentialRetry(backOffPeriod, maxAttempts: 5), | |
}; |
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
var tempFilename = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.tmp"); | |
using (var stream = new FileStream(tempFilename, FileMode.CreateNew)) | |
{ | |
const int chunkSize = 1024; | |
var buffer = new byte[chunkSize]; | |
var bytesRead = 0; | |
do | |
{ | |
bytesRead = await fileSection.FileStream.ReadAsync(buffer, 0, buffer.Length); | |
await stream.WriteAsync(buffer, 0, bytesRead); |
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
var boundary = RequestHelpers.GetBoundary(_httpContextAccessor.HttpContext.Request.ContentType); | |
var reader = new MultipartReader(boundary, _httpContextAccessor.HttpContext.Request.Body); | |
var section = await reader.ReadNextSectionAsync(); | |
var fileSection = section.AsFileSection(); | |
var originalFilename = fileSection.FileName; |