[12.x] Add processFileUsing() method to AwsS3V3Adapter for temporary local processing of remote files and get() and path() overrides #57707
+302
−80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new
processFileUsing()method to theAwsS3V3Adapterthat enables safe and temporary local processing of remote files (for example, ZIP archives) stored on S3 or any S3-compatible storage system.When working with tools like PHP’s
ZipArchive, a local file path is required — however, S3 streams cannot be passed directly.The new
processFileUsing()method provides a clean and framework-integrated solution to handle this scenario efficiently.In addition, the S3 adapter now provides ZIP-aware overrides for
get()andpath()so that ZIP files stored on S3 can be transparently copied to local storage before being read or used with APIs that expect a local filesystem path.How it works
processFileUsing()If the given file path ends with
.zip, the adapter:localdisk.For all other file types, the callback simply receives the original path.
This pattern allows developers to work with real local files when necessary, while automatically cleaning up any temporary data.
ZIP handling for
get()andpath()on S3When calling
get()for a path ending in.zipon the S3 adapter:get()then returns the contents of the local copy instead of reading directly from S3.When calling
path()for a path ending in.zipon the S3 adapter:path()returns a path that can be used with APIs (such asZipArchive) that require a local filesystem path.For non-ZIP files, both
get()andpath()keep their existing behavior and delegate to the parent implementation.Example usage