Manipulate a S3 bucket

Maintainers

Package info

github.com/Innmind/S3

Homepage

Issues

pkg:composer/innmind/s3

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

6.0.0 2026-04-12 14:43 UTC

This package is auto-updated.

Last update: 2026-04-15 12:56:09 UTC


README

CI codecov Type Coverage

Minimalist abstraction to work with any S3 bucket.

Installation

composer require innmind/s3

Usage

use Innmind\S3\{
    Factory,
    Region,
};
use Innmind\OperatingSystem\Factory as OSFactory;
use Innmind\Filesystem\File\Content;
use Innmind\Url\{
    Url,
    Path,
};

$os = OSFactory::build();

$bucket = Factory::of($os)->build(
    Url::of('https://acces_key:acces_secret@bucket-name.s3.region-name.scw.cloud/'),
    Region::of('region-name'),
);

$file = $bucket->get(Path::of('some-file.txt'))->match(
    static fn(Content $file) => $file,
    static fn() => throw new \RuntimeException('File does not exist'),
);
$bucket->upload(Path::of('some-other-name.txt'), $file)->match( // essentially this will copy the file
    static fn() => null, // everything ok
    static fn(\Throwable $e) => throw $e,
);