Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home / Living at work

Alexandru Puiu scattered-code

🏠
Working from home / Living at work
View GitHub Profile
View block-warnings.txt
! 2020-12-02 https://twitter.com
twitter.com##.r-1ny4l3l.r-1wbh5a2.r-16y2uox.css-1dbjc4n > .css-1dbjc4n > div.css-1dbjc4n > div.css-1dbjc4n > .css-1dbjc4n > .r-1g94qm0.css-1dbjc4n > .r-qvutc0.r-1w50u8q.r-m611by.r-1inuy60.r-bcqeeo.r-ad9z0x.r-16dba41.r-a023e6.r-1qd0xha.r-1loqt21.r-1n1174f.r-qklmqi.r-rull8r.r-j7yic.css-901oao.css-18t94o4.css-4rbku5
twitter.com##.r-1mi0q7o.r-1777fci.r-16y2uox.r-1iusvr4.css-1dbjc4n > div.css-1dbjc4n > div.css-1dbjc4n > .css-1dbjc4n > .r-1g94qm0.css-1dbjc4n > .r-qvutc0.r-1w50u8q.r-m611by.r-1inuy60.r-bcqeeo.r-ad9z0x.r-16dba41.r-a023e6.r-1qd0xha.r-1loqt21.r-1n1174f.r-qklmqi.r-rull8r.r-j7yic.css-901oao.css-18t94o4.css-4rbku5
twitter.com##.r-qvutc0.r-1w50u8q.r-m611by.r-1j3t67a.r-1inuy60.r-bcqeeo.r-ad9z0x.r-16dba41.r-a023e6.r-1qd0xha.r-1loqt21.r-1n1174f.r-5kkj8d.r-1efd50x.r-mxfbl1.css-901oao.css-18t94o4.css-4rbku5
View mailgun.cs
using (var httpClient = new HttpClient())
{
var authToken = Encoding.ASCII.GetBytes($"api:{_emailSettings.Value.ApiKey}");
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(authToken));
var formContent = new FormUrlEncodedContent(new Dictionary<string, string> {
{ "from", $"{_emailSettings.Value.DisplayName} <{_emailSettings.Value.From}>" },
{ "h:Reply-To", $"{_emailSettings.Value.DisplayName} <{_emailSettings.Value.ReplyTo}>" },
{ "to", email },
{ "subject", subject },
View startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddMvc();
services.Configure<FormOptions>(x =>
{
x.MultipartBodyLengthLimit = 209715200;
});
}
View program.cs
...
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = 209715200;
});
...
View DisableRequestSizeLimitKestrel.cs
[HttpPut("upload")]
[DisableRequestSizeLimit] //or [RequestFormLimits(MultipartBodyLengthLimit = 629145600)]
[RequestSizeLimit(209715200)]
public async Task Upload([FromQuery] Guid? messageId)
{
...
View DisableRequestSizeLimit.cs
[HttpPut("upload")]
[DisableRequestSizeLimit] //or [RequestFormLimits(MultipartBodyLengthLimit = 629145600)]
public async Task Upload([FromQuery] Guid? messageId)
{
...
View web.config
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="209715200" />
</requestFiltering>
</security>
</system.webServer>
View upload-multi-part-progress.cs
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;
View ProgressableStreamContent.cs
// 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
{
View upload-multi-part.cs
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;