Skip to content

add min-len and max-len parameters to mc share upload#5184

Open
devnewton wants to merge 3 commits into
minio:masterfrom
devnewton:mc_share_contentlengthrange
Open

add min-len and max-len parameters to mc share upload#5184
devnewton wants to merge 3 commits into
minio:masterfrom
devnewton:mc_share_contentlengthrange

Conversation

@devnewton

Copy link
Copy Markdown

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 (...) -Ffile=@afilebiggerthantwobytes.txt

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • 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 :-(
  • 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.

@shtripat

shtripat commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

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 file=@info.txt

$ 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

@devnewton

Copy link
Copy Markdown
Author

I forgot to check the error returned by SetContentLengthRange. It ensures than min-len is smaller than max-len.

@stale

stale Bot commented Jul 19, 2025

Copy link
Copy Markdown

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.

@stale stale Bot added the stale label Jul 19, 2025
@stale stale Bot removed the stale label Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants