45 throw new InvalidArgumentException(
"FileBackendGroup required in 'fbGroup' field." );
47 $this->fbGroup =
$params[
'fbGroup'];
58 $be = $this->fbGroup->backendFromPath( $url );
62 return $be->getFileContents( [
'src' => $url ] );
77 foreach ( $urls as $url ) {
78 $be = $this->fbGroup->backendFromPath( $url );
80 $pathsByBackend[$be->getName()][] = $url;
84 foreach ( $pathsByBackend as $backendName => $paths ) {
85 $be = $this->fbGroup->get( $backendName );
86 $blobs += $be->getFileContentsMulti( [
'srcs' => $paths ] );
95 public function store( $backend, $data ) {
96 $be = $this->fbGroup->get( $backend );
98 $rand = Wikimedia\base_convert( mt_rand( 0, 46655 ), 10, 36, 3 );
100 $id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26,
'0', STR_PAD_LEFT );
102 $domain = $this->isDbDomainExplicit
105 : WikiMap::getWikiIdFromDbDomain( $this->dbDomain );
106 $url = $be->getContainerStoragePath(
'data' ) .
'/' . rawurlencode( $domain );
109 ?
"/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}"
110 :
"/{$rand[0]}/{$rand[1]}/{$id}";
112 $be->prepare( [
'dir' => dirname( $url ),
'noAccess' => 1,
'noListing' => 1 ] );
113 $status = $be->create( [
'dst' => $url,
'content' => $data ] );
115 if ( $status->isOK() ) {
119 throw new MWException( __METHOD__ .
": operation failed: $status" );
123 if ( parent::isReadOnly( $backend ) ) {
127 $be = $this->fbGroup->get( $backend );
129 return $be ? $be->isReadOnly() :
false;
Key/value blob storage for a particular storage medium type (e.g.
array $params
Usage context options for this instance.
File backend accessible external objects.
batchFetchFromURLs(array $urls)
Fetch data from given external store URLs.
FileBackendGroup $fbGroup
isReadOnly( $backend)
Check if a given location is read-only.
store( $backend, $data)
Insert a data item into a given location.string|bool The URL of the stored data item,...
__construct(array $params)
fetchFromURL( $url)
The URL returned is of the form of the form mwstore://backend/container/wiki/id.
Class for a file system (FS) based file backend.
Class to handle file backend registration.
Base class for all file backend classes (including multi-write backends).