Skip to content

feat: s3 transfer manager v2 #3079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3093732
feat: s3 transfer manager v2
yenfryherrerafeliz Feb 2, 2025
5950c31
chore: add tests cases and refactor
yenfryherrerafeliz Feb 6, 2025
1c82ab5
chore: add multipart download listener tests
yenfryherrerafeliz Feb 6, 2025
237fc7b
chore: refactor multipart downloaders and add tests
yenfryherrerafeliz Feb 6, 2025
c28c165
feat: add download directory and refactor code
yenfryherrerafeliz Feb 13, 2025
34321b2
chore: add upload and refactor code
yenfryherrerafeliz Feb 14, 2025
5289f7c
feat: add upload directory feature
yenfryherrerafeliz Feb 14, 2025
c6c0780
feat: multipart upload and some refactor
yenfryherrerafeliz Feb 17, 2025
034b50d
chore: short namespace
yenfryherrerafeliz Feb 17, 2025
bc15ac3
chore: refactor and address feedback
yenfryherrerafeliz Feb 22, 2025
e681d10
chore: fix test cases
yenfryherrerafeliz Feb 24, 2025
1f094cd
chore: remove unused implementation
yenfryherrerafeliz Feb 24, 2025
464b498
chore: remove invalid test
yenfryherrerafeliz Feb 24, 2025
09e493f
fix: add nullable type
yenfryherrerafeliz Feb 24, 2025
f10522b
chore: add more tests
yenfryherrerafeliz Feb 26, 2025
a55e1b3
chore: add upload unit tests and refactor
yenfryherrerafeliz Mar 13, 2025
b271897
chore: address naming feedback and test failures
yenfryherrerafeliz Mar 13, 2025
f4f1c88
chore: address minor styling issues
yenfryherrerafeliz Mar 13, 2025
d987aff
chore: add download tests
yenfryherrerafeliz Mar 17, 2025
6d000f1
chore: add integ tests
yenfryherrerafeliz May 19, 2025
27570d0
chore: add integ test
yenfryherrerafeliz May 20, 2025
1dde7fc
chore: address PR feedback
yenfryherrerafeliz May 26, 2025
060e0e1
chore: fix and refactor
yenfryherrerafeliz May 27, 2025
ee0fefb
chore: fix TransferListener import
yenfryherrerafeliz May 27, 2025
9f639f1
chore: add test case
yenfryherrerafeliz May 29, 2025
bdce369
chore: address PR feedback
yenfryherrerafeliz Jun 4, 2025
cd2133a
fix: prevent calling twice downloadFailed
yenfryherrerafeliz Jun 5, 2025
0426e11
chore: fix exception throwing
yenfryherrerafeliz Jun 5, 2025
a548ce2
feat: consider checksum mode from command
yenfryherrerafeliz Jun 17, 2025
5a25ad8
chore: tests and minor fixes
yenfryherrerafeliz Jun 18, 2025
64fc3f6
tests: Add integ test for abort
yenfryherrerafeliz Jun 18, 2025
908b4a0
chore: update integ test
yenfryherrerafeliz Jun 18, 2025
1e643e5
feat: update to use modeled inputs
yenfryherrerafeliz Jul 10, 2025
48a2822
chore: multipart download updates
yenfryherrerafeliz Jul 15, 2025
02b43f0
chore: s3 transfer manager updates
yenfryherrerafeliz Jul 17, 2025
153227b
chore: minor update
yenfryherrerafeliz Jul 17, 2025
31dbd19
chore: add empty lines at the end
yenfryherrerafeliz Jul 17, 2025
aeed758
chore: remove unused implementations
yenfryherrerafeliz Jul 17, 2025
26d2469
fix: object key should be normalized
yenfryherrerafeliz Jul 17, 2025
10928ca
fix: minor logic and test fix
yenfryherrerafeliz Jul 18, 2025
632ece9
fix: fix s3 delimiter test
yenfryherrerafeliz Jul 18, 2025
6efcc0a
fix: wrong data provider name used
yenfryherrerafeliz Jul 18, 2025
b0c5f75
chore: addressed some styling
yenfryherrerafeliz Jul 18, 2025
44f6ff4
chore: update argument name
yenfryherrerafeliz Jul 18, 2025
83ccd9b
chore: make config optional
yenfryherrerafeliz Jul 22, 2025
039a67b
chore: minor refactor and fix
yenfryherrerafeliz Jul 23, 2025
50715d1
chore: make parameter optional
yenfryherrerafeliz Jul 23, 2025
3034ad8
chore: make model classes final
yenfryherrerafeliz Jul 28, 2025
cfe4ab5
chore: make classes final and refactor tests
yenfryherrerafeliz Jul 29, 2025
f4c42e0
chore: fix and reformat integ test
yenfryherrerafeliz Jul 30, 2025
9fb03f1
chore: address some styling suggestions
yenfryherrerafeliz Jul 31, 2025
4268266
chore: address PR suggestions
yenfryherrerafeliz Aug 4, 2025
59a8aa4
chore: null as default
yenfryherrerafeliz Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions src/S3/S3Transfer/ConsoleProgressBar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php

namespace Aws\S3\S3Transfer;

class ConsoleProgressBar implements ProgressBar
{
public const BLACK_COLOR_CODE = '[30m';
public const BLUE_COLOR_CODE = '[34m';
public const GREEN_COLOR_CODE = '[32m';
public const RED_COLOR_CODE = '[31m';
public const PLAIN_FORMAT = 'plain';
public const TRANSFER_FORMAT = 'transfer_format';
public const COLORED_TRANSFER_FORMAT = 'colored_transfer_format';

/** @var array|array[] */
public static array $formats = [
'plain' => [
'format' => "[|progress_bar|] |percent|%",
'parameters' => []
],
'transfer_format' => [
'format' => "[|progress_bar|] |percent|% |transferred|/|tobe_transferred| |unit|",
'parameters' => [
'transferred',
'tobe_transferred',
'unit'
]
],
'colored_transfer_format' => [
'format' => "\033|color_code|[|progress_bar|] |percent|% |transferred|/|tobe_transferred| |unit| |message|\033[0m",
'parameters' => [
'transferred',
'tobe_transferred',
'unit',
'color_code',
'message'
]
],
];

/** @var string */
private string $progressBarChar;

/** @var int */
private int $progressBarWidth;

/** @var int */
private int $percentCompleted;

/** @var ?array */
private ?array $format;

/** @var array */
private array $args;

/**
* @param ?string $progressBarChar
* @param ?int $progressBarWidth
* @param ?int $percentCompleted
* @param array|null $format
* @param array $args
*/
public function __construct(
?string $progressBarChar = null,
?int $progressBarWidth = null,
?int $percentCompleted = null,
?array $format = null,
array $args = [],
) {
$this->progressBarChar = $progressBarChar ?? '#';
$this->progressBarWidth = $progressBarWidth ?? 25;
$this->percentCompleted = $percentCompleted ?? 0;
$this->format = $format ?? self::$formats['transfer_format'];
$this->args = $args ?? [];
}

/**
* Set current progress percent.
*
* @param int $percent
*
* @return void
*/
public function setPercentCompleted(int $percent): void
{
$this->percentCompleted = max(0, min(100, $percent));
}

/**
* @param array $args
*
* @return void
*/
public function setArgs(array $args): void
{
$this->args = $args;
}

/**
* Sets an argument.
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public function setArg(string $key, mixed $value): void
{
$this->args[$key] = $value;
}

private function renderProgressBar(): string
{
$filledWidth = (int) round(($this->progressBarWidth * $this->percentCompleted) / 100);
return str_repeat($this->progressBarChar, $filledWidth)
. str_repeat(' ', $this->progressBarWidth - $filledWidth);
}

/**
*
* @return string
*/
public function getPaintedProgress(): string
{
foreach ($this->format['parameters'] as $param) {
if (!array_key_exists($param, $this->args)) {
$this->args[$param] = '';
}
}

$replacements = [
'|progress_bar|' => $this->renderProgressBar(),
'|percent|' => $this->percentCompleted,
];

foreach ($this->format['parameters'] as $param) {
$replacements["|$param|"] = $this->args[$param] ?? '';
}

return strtr($this->format['format'], $replacements);
}
}
Loading
Loading