thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.37k stars 827 forks source link

Limit S3 bandwidth #1792

Open Maxence1502 opened 6 months ago

Maxence1502 commented 6 months ago

Hello,

I'm using this version of your library: https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.x

I need to limit the bandwidth to 500 Mbps so as not to saturate my connection when uploading very large files. I haven't found any documentation on the subject, is there a parameter to do this?

Thanks

Maxence1502 commented 6 months ago

I found this parameter for AWS SDK : https://docs.aws.amazon.com/cli/latest/topic/s3-config.html#max-bandwidth

But I don't know how to use it via Flysystem

SamMousa commented 3 months ago

Bandwidth limiting is part of the CLI, not of the S3 API as far as I can tell. Assuming you're uploading files via writeStream it should be possible to implement a RateLimitingAdapter decorator.

Maxence1502 commented 3 months ago

Do you know how to do that ?

SamMousa commented 3 months ago

I do not at this moment. It's solvable via PHP stream wrappers, but you'll have to do the research yourself.

jgivoni commented 2 months ago

To create a RateLimitingAdapteror LimitUploadBandwithAdapter wrapper, you could extend DecoratedAdapter and just override write() and writeStream() with functions that create a new stream (extend StreamInterface) with a built-in periodical 'delay'.