arraypress / wp-s3-browser
A comprehensive PHP library for integrating S3-compatible storage providers with WordPress. Features advanced media browser, upload/download management, presigned URLs, and support for multiple providers including AWS S3, Cloudflare R2, DigitalOcean Spaces, and more.
Requires
- php: >=8.3
- arraypress/wp-breadcrumbs: ^1.1
- arraypress/wp-composer-assets: ^2.2
- arraypress/wp-s3-signer: ^2.0
Requires (Dev)
- phpcompatibility/phpcompatibility-wp: ^2.1
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.13.5
- wp-coding-standards/wpcs: ^3.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v4.12.3
- v4.12.2
- v4.12.1
- v4.12.0
- v4.11.1
- v4.11.0
- v4.10.0
- v4.9.0
- v4.8.1
- v4.8.0
- v4.7.2
- v4.7.1
- v4.7.0
- v4.6.1
- v4.6.0
- v4.5.1
- v4.5.0
- v4.4.0
- v4.3.0
- v4.2.0
- v4.1.0
- v4.0.1
- v4.0.0
- v3.1.2
- 3.1.0
- 3.0.0
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- v1.0.0
This package is auto-updated.
Last update: 2026-11-18 10:54:57 UTC
README
This library has moved. It is now part of
sugarcommerce/storage(namespaceSugarCommerce\Storage, PHP 8.3+). That package's README has a "Moving from arraypress/wp-*" table. This repository is archived and read-only.
S3 Browser
A media browser for S3-compatible storage, inside the WordPress admin.
What it does
Files sold as downloads usually live in object storage rather than the media library, and the moment they do, attaching one to a product means copying a key out of another tab.
This adds a browser beside the media library: buckets, folders, search,
upload and a link back into whatever field asked for it. Underneath it is
arraypress/wp-s3-signer, so nothing is made public and uploads go straight
from the browser to storage rather than through PHP.
Features
- Browse buckets and folders from the admin, without leaving WordPress
- Upload straight to storage from the browser, bypassing the PHP upload limit
- Attach a file to a field, the way the media library does
- Confine a browser to one bucket, or to certain post types
- Require a capability, so not everyone who can edit can see storage
- Run more than one browser on a site, each on its own provider and context
- Work against R2, B2, Wasabi, DigitalOcean, MinIO or anything S3-compatible
Installation
composer require arraypress/wp-s3-browser
Quick start
use ArrayPress\S3\Browser; use ArrayPress\S3\Provider; $browser = new Browser( Provider::r2( 'your-account-id' ), $access_key, $secret_key, [ 'download' ], // post types this browser appears for; [] means all 'my-bucket', // bucket it opens on 'upload_files', // capability required to use it 'edd' // context: which integration this instance serves ); $browser->set_allowed_buckets( [ 'my-bucket' ] );
Confining it to one bucket is worth doing whenever you can — the credentials usually reach more than the browser should.
Pages that are not post editors
A post editor is recognised by its post type. A plugin with screens of its own — a settings page, a custom list, a panel — has no post type to be recognised by, so it names the page and says where a chosen file goes:
add_action( 'admin_enqueue_scripts', function ( $hook ) use ( $browser ) { if ( 'toplevel_page_my-shop' === $hook ) { $browser->set_host_hook( $hook ); } }, 5 );
window.S3BrowserHost = { insert: function ( files ) { // files: [ { fileName, bucket, key } ] } };
The browser then appears as a tab in any media frame that page opens. The
page owns its fields, so it is asked rather than written into: throw from
insert and the frame stays open with the selection still in it.
Uploads need CORS
Uploading from the browser is a cross-origin request, so the bucket has to
allow it. Setting that rule needs an admin token: a key with Object Read &
Write cannot call PutBucketCors, and the error it returns says
AccessDenied, which reads like a bucket-permissions problem rather than a
key-permissions one.
Icons
Buckets, folders, file types and upload states are drawn as Heroicons
(outline, inline SVG) when arraypress/wp-field-kit is installed, and as the
Dashicons they replaced when it is not. Every icon carries the class
arraypress-icon, so a stylesheet that restyles them has one class to
target either way.
Requirements
- PHP 8.3 or later
- WordPress 7.1 or later
- Credentials for an S3-compatible provider
arraypress/wp-field-kit(optional), for Heroicons
License
GPL-2.0-or-later