Skip to content

Commit ac96a39

Browse files
authored
Merge pull request #7725 from tangledbytes/utkarsh/add/prohibit-standard-upload
Add configuration to deny upload to "STANDARD" storage class
2 parents 38d8d28 + 8e67135 commit ac96a39

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ config.S3_CORS_EXPOSE_HEADERS = [
172172
].join(',');
173173
config.STS_CORS_EXPOSE_HEADERS = 'ETag';
174174

175+
config.DENY_UPLOAD_TO_STORAGE_CLASS_STANDARD = false;
176+
175177
/////////////////////
176178
// SECRETS CONFIG //
177179
/////////////////////

src/endpoint/s3/ops/s3_post_object_uploads.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
const s3_utils = require('../s3_utils');
55
const mime = require('mime');
6+
const config = require('../../../../config');
7+
const S3Error = require('../s3_errors').S3Error;
68

79
/**
810
* http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadInitiate.html
@@ -12,6 +14,10 @@ async function post_object_uploads(req, res) {
1214
const tagging = s3_utils.parse_tagging_header(req);
1315
const encryption = s3_utils.parse_encryption(req);
1416
const storage_class = s3_utils.parse_storage_class_header(req);
17+
if (config.DENY_UPLOAD_TO_STORAGE_CLASS_STANDARD && storage_class === s3_utils.STORAGE_CLASS_STANDARD) {
18+
throw new S3Error(S3Error.InvalidStorageClass);
19+
}
20+
1521
const reply = await req.object_sdk.create_object_upload({
1622
bucket: req.params.bucket,
1723
key: req.params.key,

src/endpoint/s3/ops/s3_put_object.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ async function put_object(req, res) {
2121
const copy_source = s3_utils.parse_copy_source(req);
2222
const tagging = s3_utils.parse_tagging_header(req);
2323
const storage_class = s3_utils.parse_storage_class_header(req);
24+
if (config.DENY_UPLOAD_TO_STORAGE_CLASS_STANDARD && storage_class === s3_utils.STORAGE_CLASS_STANDARD) {
25+
throw new S3Error(S3Error.InvalidStorageClass);
26+
}
2427
const lock_settings = config.WORM_ENABLED ? s3_utils.parse_lock_header(req) : undefined;
2528
// Copy request sends empty content and not relevant to the object data
2629
const { size, md5_b64, sha256_b64 } = copy_source ? {} : {

0 commit comments

Comments
 (0)