add min-len and max-len parameters to mc share upload
Community Contribution License
All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 license. By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 license.
Description
Allow to specify content length range with mc share upload command.
Motivation and Context
This is usefull to share upload link with length restriction.
This feature is already present in minio java client.
How to test this PR?
Create a test bucket on play server and share an upload using --max-len parameter then upload a file larger than expected:
mc mb play/mytest
mc share upload --max-len 2 play/mytest/info.txt
curl (...) [email protected]
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Optimization (provides speedup with no functional changes)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [ ] Unit tests added/updated => I'm dont know how to do this for this kind feature :-(
- [x] Internal documentation updated
- [ ] Create a documentation update request here => I've updated the cli help. I will create the documentation update if this pull request is accepted.
max-len setting seems working but min-len doesn't seems be working as expected
$ mc mb play/shubhendu-bkt2
Bucket created successfully `play/shubhendu-bkt2`.
$ echo "hello" > info.txt
$ ls -lrt info.txt
-rw-r--r-- 1 shubhendu shubhendu 6 Apr 3 21:29 info.txt
$ ./mc share upload --min-len 2048 play/shubhendu-bkt2/info.txt
URL: https://play.min.io/shubhendu-bkt2/info.txt
Expire: 7 days 0 hours 0 minutes 0 seconds
Share: curl https://play.min.io/shubhendu-bkt2/ -F policy=eyJleHBpcmF0aW9uIjoiMjAyNS0wNC0xMFQxNjowMDoyNS42MjRaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIkYnVja2V0Iiwic2h1YmhlbmR1LWJrdDIiXSxbImVxIiwiJGtleSIsImluZm8udHh0Il0sWyJlcSIsIiR4LWFtei1kYXRlIiwiMjAyNTA0MDNUMTYwMDI2WiJdLFsiZXEiLCIkeC1hbXotYWxnb3JpdGhtIiwiQVdTNC1ITUFDLVNIQTI1NiJdLFsiZXEiLCIkeC1hbXotY3JlZGVudGlhbCIsIlEzQU0zVVE4NjdTUFFRQTQzUDJGLzIwMjUwNDAzL3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QiXV19 -F x-amz-algorithm=AWS4-HMAC-SHA256 -F x-amz-credential=Q3AM3UQ867SPQQA43P2F/20250403/us-east-1/s3/aws4_request -F x-amz-date=20250403T160026Z -F x-amz-signature=07c24ea645ad9b2d0bf1eb082438d0dccedded0641a4ce2a41696936b935ba25 -F bucket=shubhendu-bkt2 -F key=info.txt -F file=@<FILE>
$ curl https://play.min.io/shubhendu-bkt2/ -F policy=eyJleHBpcmF0aW9uIjoiMjAyNS0wNC0xMFQxNjowMDoyNS42MjRaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIkYnVja2V0Iiwic2h1YmhlbmR1LWJrdDIiXSxbImVxIiwiJGtleSIsImluZm8udHh0Il0sWyJlcSIsIiR4LWFtei1kYXRlIiwiMjAyNTA0MDNUMTYwMDI2WiJdLFsiZXEiLCIkeC1hbXotYWxnb3JpdGhtIiwiQVdTNC1ITUFDLVNIQTI1NiJdLFsiZXEiLCIkeC1hbXotY3JlZGVudGlhbCIsIlEzQU0zVVE4NjdTUFFRQTQzUDJGLzIwMjUwNDAzL3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QiXV19 -F x-amz-algorithm=AWS4-HMAC-SHA256 -F x-amz-credential=Q3AM3UQ867SPQQA43P2F/20250403/us-east-1/s3/aws4_request -F x-amz-date=20250403T160026Z -F x-amz-signature=07c24ea645ad9b2d0bf1eb082438d0dccedded0641a4ce2a41696936b935ba25 -F bucket=shubhendu-bkt2 -F key=info.txt -F [email protected]
$ mc ls play/shubhendu-bkt2
[2025-04-03 21:30:39 IST] 6B STANDARD info.txt
expected curl upload to fail as upload size if 6B and min-len was set as 2048
I forgot to check the error returned by SetContentLengthRange. It ensures than min-len is smaller than max-len.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.