AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

MongoDB\GridFS\Bucket::__construct()

MongoDB\GridFS\Bucket::__construct()

新しいBucketインスタンスを構築します。

function __construct(
MongoDB\Driver\Manager $manager,
string $databaseName,
array $options = []
)
$manager : MongoDB\Driver\Manager
拡張機能からの マネージャーインスタンス。マネージャーはドライバーとMongoDBの間の接続を維持します。
$databaseName : string
データベースの名前。
$options : 配列

必要なオプションを指定する配列。

名前
タイプ
説明

bucketName

string

ファイルとチャンク コレクションのプレフィックスとして使用されるバケット名。 デフォルトは"fs"です。

chunkSizeBytes

integer

バイト単位での チャンク サイズ 。 デフォルトは261120 ( 255 キー B)。

コーデック

MongoDB\Codec\DocumentCodec

タイプ コーデックでデータをエンコードするデフォルトのエンコード メソッドは、ファイルドキュメントを返すバケットメソッド(例:MongoDB\GridFS\Bucket::find())。

バージョン1.17の新機能。

disableMD5

ブール値

ファイルを保存するときに MD5 の自動生成を無効にするかどうか。

デフォルトはfalseです。 2.0ではtrueのみがサポートされます。

バージョン1.4の新機能。

ReadConcern

バケット操作に使用するデフォルトの読み取り保証 (read concern) です。 デフォルトは、マネージャーの読み取り保証 (read concern) です。

readPreference

バケット操作に使用するデフォルトの読み込み設定 (read preference) 。 デフォルトは、マネージャーの読み込み設定 (read preference) です。

typeMap

配列

Default type map to apply to cursors, which determines how BSON documents are converted to PHP values. The library uses the following type map by default:

[
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
]

writeConcern

バケット操作に使用するデフォルトの書込み保証 (write concern) です。 デフォルトは、マネージャーの書込み保証 (write concern) です。

MongoDB\Exception\InvalidArgumentException は、パラメータまたはオプションの解析に関連するエラーの場合は です。

If you construct a Bucket explicitly, the Bucket inherits any options from the MongoDB\Driver\Manager object. If you select the Bucket from a Database object, the Bucket inherits its options from that object.

<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket);

出力は次のようになります。

object(MongoDB\GridFS\Bucket)#3053 (2) {
["bucketName"]=>
string(4) "test"
["databaseName"]=>
string(11) "phplib_test"
}