GridFS

public final class GridFS

A GridFS instance similar to a collection

Conforms to the GridFS standard as specified here: https://docs.mongodb.org/manual/core/gridfs/

  • The bucket for file data

    Declaration

    Swift

    public let files: Collection
  • The bucket for file data chunks

    Declaration

    Swift

    public let chunks: Collection
  • The GridFS bucket name

    Declaration

    Swift

    public let name: String
  • Drops the GridFS bucket’s collections

    Declaration

    Swift

    public func drop() throws
  • Initializes a GridFS Collection (bucket) in a given database

    Throws

    When unable to send the request/receive the response, the authenticated user doesn’t have sufficient permissions or an error occurred or when it can’t create it’s indexes

    Declaration

    Swift

    public init(in database: Database, named bucketName: String = "fs") throws
  • Finds the first file matching this ObjectID

    Throws

    When unable to send the request/receive the response, the authenticated user doesn’t have sufficient permissions or an error occurred

    Declaration

    Swift

    public func findOne(byID id: ObjectId) throws -> File?

    Return Value

    The resulting file

  • Finds using a matching filter

    Throws

    When unable to send the request/receive the response, the authenticated user doesn’t have sufficient permissions or an error occurred

    Declaration

    Swift

    public func find(_ filter: Query? = nil) throws -> Cursor<File>

    Return Value

    A cursor pointing to all resulting files

  • Removes a file by it’s identifier

    Declaration

    Swift

    public func remove(byId identifier: ObjectId) throws
  • Stores the data in GridFS

    TODO: Accept data streams

    Declaration

    Swift

    public func store(data binary: Bytes, named filename: String? = nil, withType contentType: String? = nil, usingMetadata metadata: BSON.Primitive? = nil, inChunksOf chunkSize: Int = 255_000) throws -> ObjectId
  • Stores the data in GridFS

    Declaration

    Swift

    public func store(data: Data, named filename: String? = nil, withType contentType: String? = nil, usingMetadata metadata: BSON.Primitive? = nil, inChunksOf chunkSize: Int = 255000) throws -> ObjectId
  • A file in GridFS

    See more

    Declaration

    Swift

    public final class File: Sequence
  • Makes GridFS descriptive

    Declaration

    Swift

    public var description: String