46 throw new InvalidArgumentException(
"FileBackendGroup required in 'fbGroup' field." );
48 $this->fbGroup =
$params[
'fbGroup'];
59 $be = $this->fbGroup->backendFromPath( $url );
63 return $be->getFileContents( [
'src' => $url ] );
78 foreach ( $urls as $url ) {
79 $be = $this->fbGroup->backendFromPath( $url );
81 $pathsByBackend[$be->getName()][] = $url;
85 foreach ( $pathsByBackend as $backendName => $paths ) {
86 $be = $this->fbGroup->get( $backendName );
87 $blobs += $be->getFileContentsMulti( [
'srcs' => $paths ] );
93 public function store( $backend, $data ) {
94 $be = $this->fbGroup->get( $backend );
96 $rand = Wikimedia\base_convert( (
string)mt_rand( 0, 46655 ), 10, 36, 3 );
100 $domain = $this->isDbDomainExplicit
103 : WikiMap::getWikiIdFromDbDomain( $this->dbDomain );
104 $url = $be->getContainerStoragePath(
'data' ) .
'/' . rawurlencode( $domain );
107 ?
"/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}"
108 :
"/{$rand[0]}/{$rand[1]}/{$id}";
110 $be->prepare( [
'dir' => dirname( $url ),
'noAccess' => 1,
'noListing' => 1 ] );
111 $status = $be->create( [
'dst' => $url,
'content' => $data ] );
113 if ( $status->isOK() ) {
117 throw new MWException( __METHOD__ .
": operation failed: $status" );
121 if ( parent::isReadOnly( $backend ) ) {
125 $be = $this->fbGroup->get( $backend );
127 return $be->isReadOnly();
Base class for external storage.
array $params
Usage context options for this instance.
External storage in a FileBackend.
batchFetchFromURLs(array $urls)
Fetch data from given external store URLs.
isReadOnly( $backend)
Check if a given location is read-only.
store( $backend, $data)
Insert a data item into a given location.
__construct(array $params)
fetchFromURL( $url)
Fetch data from a given external store URL.
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).
static newTimestampedUID128( $base=10)
Get a statistically unique 128-bit unsigned integer ID string.