44 throw new InvalidArgumentException(
"FileBackendGroup required in 'fbGroup' field." );
46 $this->fbGroup =
$params[
'fbGroup'];
57 $be = $this->fbGroup->backendFromPath( $url );
61 return $be->getFileContents( [
'src' => $url ] );
76 foreach ( $urls as $url ) {
77 $be = $this->fbGroup->backendFromPath( $url );
79 $pathsByBackend[$be->getName()][] = $url;
83 foreach ( $pathsByBackend as $backendName => $paths ) {
84 $be = $this->fbGroup->get( $backendName );
85 $blobs += $be->getFileContentsMulti( [
'srcs' => $paths ] );
91 public function store( $backend, $data ) {
92 $be = $this->fbGroup->get( $backend );
94 $rand = Wikimedia\base_convert( (
string)mt_rand( 0, 46655 ), 10, 36, 3 );
98 $domain = $this->isDbDomainExplicit
101 : WikiMap::getWikiIdFromDbDomain( $this->dbDomain );
102 $url = $be->getContainerStoragePath(
'data' ) .
'/' . rawurlencode( $domain );
105 ?
"/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}"
106 :
"/{$rand[0]}/{$rand[1]}/{$id}";
108 $be->prepare( [
'dir' => dirname( $url ),
'noAccess' => 1,
'noListing' => 1 ] );
109 $status = $be->create( [
'dst' => $url,
'content' => $data ] );
111 if ( $status->isOK() ) {
115 throw new MWException( __METHOD__ .
": operation failed: $status" );
119 if ( parent::isReadOnly( $backend ) ) {
123 $be = $this->fbGroup->get( $backend );
125 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.