Skip to content
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

Add the possibility to implement a callback after each file transfer is fulfilled when using the Transfer class in S3 #2725

Open
1 of 2 tasks
madalindk opened this issue Jul 11, 2023 · 1 comment · May be fixed by #2723
Open
1 of 2 tasks
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue queued This issues is on the AWS team's backlog

Comments

@madalindk
Copy link

Describe the feature

The SDK offers the possibility to transfer files to and from an S3 Object Storage using the Transfer class.
Currently it is possible to implement a callback before each Command is executed but there is no possibility of implementing a callback after the Command has been executed.

Example of the "before" callback:

$s3Client->uploadDirectory($path, $bucket, null, [
    'before' => function (\Aws\Command $command) {
        // Do something with the $command
    }
]);

I would like to request the feature that we could write another type of callback to be executed "after" the command is executed.
Such a feature would be easy to implement with a minimum amount of changes and would open more of the S3 transfer SDK possibilities.

Use Case

As I had to implement a buffered S3 client (the buffer being represented by saving files on disk before they will be transferred to S3 later on) I could not easily cleanup the files that were already transferred because there is no "after" callback function.

With the proposed solution one could use something like:

$s3Client->uploadDirectory($path, $bucket, null, [
    'after' => function(\Aws\Result $result, int $index, \GuzzleHttp\Promise\Promise $aggregatePromise) {
        // Do something with $result or check $aggregatePromise
    }
]);

Proposed Solution

Implementing an "after" callback in a similar way to how the "before" callback is working now.
Basically sending a callable as part of the options parameter to the existing functions.
For the upload methods the callable would just need to be passed further to the Promise\Each::ofLimitAll as the 3rd parameter (onFulfilled) when creating the upload promise.
For the download methods the callable would just need to be sent as part of the CommandPool constructor options as fulfill.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

3.275.6

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 7.2.24-0ubuntu0.18.04.17

@madalindk madalindk added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 11, 2023
@madalindk madalindk linked a pull request Jul 11, 2023 that will close this issue
@yenfryherrerafeliz yenfryherrerafeliz added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jul 12, 2023
@yenfryherrerafeliz yenfryherrerafeliz added the queued This issues is on the AWS team's backlog label Dec 5, 2023
@peterlh
Copy link

peterlh commented Mar 21, 2024

Any updates on this PR #2723 ?
This feature would be very useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue queued This issues is on the AWS team's backlog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants