1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

Fix upload limits for direct uploads (again) (#1479)

* Use constants to represent file size limits

* Allow uploads of up to 500mb for self-hosted

* Set nginx max body size to 505mb

* Add reminder about updating nginx/proxy.conf
This commit is contained in:
Thomas Rittson
2021-08-04 09:00:30 +10:00
committed by GitHub
parent a31c231749
commit b1ed6d2c21
6 changed files with 21 additions and 13 deletions

View File

@ -17,6 +17,7 @@ using Microsoft.Azure.EventGrid.Models;
using Bit.Core.Models.Data;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Bit.Core;
namespace Bit.Api.Controllers
{
@ -622,7 +623,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("{id}/attachment/{attachmentId}")]
[DisableRequestSizeLimit]
[RequestSizeLimit(Constants.FileSize501mb)]
[DisableFormValueModelBinding]
public async Task PostFileForExistingAttachment(string id, string attachmentId)
{
@ -652,7 +653,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("{id}/attachment")]
[RequestSizeLimit(105_906_176)]
[RequestSizeLimit(Constants.FileSize101mb)]
[DisableFormValueModelBinding]
public async Task<CipherResponseModel> PostAttachment(string id)
{
@ -676,7 +677,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("{id}/attachment-admin")]
[RequestSizeLimit(105_906_176)]
[RequestSizeLimit(Constants.FileSize101mb)]
[DisableFormValueModelBinding]
public async Task<CipherMiniResponseModel> PostAttachmentAdmin(string id)
{
@ -709,7 +710,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("{id}/attachment/{attachmentId}/share")]
[RequestSizeLimit(105_906_176)]
[RequestSizeLimit(Constants.FileSize101mb)]
[DisableFormValueModelBinding]
public async Task PostAttachmentShare(string id, string attachmentId, Guid organizationId)
{
@ -805,7 +806,7 @@ namespace Bit.Api.Controllers
throw new BadRequestException("Invalid content.");
}
if (Request.ContentLength > 105906176) // 101 MB, give em' 1 extra MB for cushion
if (Request.ContentLength > Constants.FileSize101mb)
{
throw new BadRequestException("Max file size is 100 MB.");
}

View File

@ -19,6 +19,7 @@ using Bit.Core.Models.Table;
using Newtonsoft.Json;
using Bit.Core.Models.Data;
using Microsoft.Extensions.Logging;
using Bit.Core;
namespace Bit.Api.Controllers
{
@ -166,7 +167,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("file")]
[RequestSizeLimit(105_906_176)]
[RequestSizeLimit(Constants.FileSize101mb)]
[DisableFormValueModelBinding]
public async Task<SendResponseModel> PostFile()
{
@ -175,7 +176,7 @@ namespace Bit.Api.Controllers
throw new BadRequestException("Invalid content.");
}
if (Request.ContentLength > 105906176) // 101 MB, give em' 1 extra MB for cushion
if (Request.ContentLength > Constants.FileSize101mb)
{
throw new BadRequestException("Max file size is 100 MB.");
}
@ -249,7 +250,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("{id}/file/{fileId}")]
[DisableRequestSizeLimit]
[RequestSizeLimit(Constants.FileSize501mb)]
[DisableFormValueModelBinding]
public async Task PostFileForExistingSend(string id, string fileId)
{
@ -258,7 +259,7 @@ namespace Bit.Api.Controllers
throw new BadRequestException("Invalid content.");
}
if (Request.ContentLength > 105906176 && !_globalSettings.SelfHosted) // 101 MB, give em' 1 extra MB for cushion
if (Request.ContentLength > Constants.FileSize101mb && !_globalSettings.SelfHosted)
{
throw new BadRequestException("Max file size for direct upload is 100 MB.");
}