Mongo.GridFs.UploadStream (mongodb-driver v1.4.0) View Source

This is the upload stream for save streams into the grid fs.

First you need to create a bucket. The bucket contains the configuration for the grid fs.

Example:

streaming the file ./test/data/test.jpg into the grid fs using the upload-stream

bucket = Bucket.new( pid )
upload_stream = Upload.open_upload_stream(bucket, "test.jpg", j: true)

src_filename = "./test/data/test.jpg"
File.stream!(src_filename, [], 512) |> Stream.into(upload_stream) |> Stream.run()

Link to this section Summary

Functions

Creates a new upload stream to insert a file into the grid-fs.

Link to this section Types

Specs

file_id() :: BSON.ObjectId.t() | binary()

Specs

t() :: %Mongo.GridFs.UploadStream{
  bucket: Mongo.GridFs.Bucket.t(),
  filename: String.t(),
  id: file_id(),
  metadata: {BSON.document() | nil}
}

Link to this section Functions

Link to this function

new(bucket, filename, metadata \\ nil, file_id \\ nil)

View Source

Specs

new(Mongo.GridFs.Bucket.t(), String.t(), BSON.document() | nil, file_id() | nil) ::
  t()

Creates a new upload stream to insert a file into the grid-fs.