...

Source file src/go.mongodb.org/mongo-driver/mongo/gridfs/doc.go

Documentation: go.mongodb.org/mongo-driver/mongo/gridfs

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  // Package gridfs provides a MongoDB GridFS API. See https://www.mongodb.com/docs/manual/core/gridfs/ for more
     8  // information about GridFS and its use cases.
     9  //
    10  // # Buckets
    11  //
    12  // The main type defined in this package is Bucket. A Bucket wraps a mongo.Database instance and operates on two
    13  // collections in the database. The first is the files collection, which contains one metadata document per file stored
    14  // in the bucket. This collection is named "<bucket name>.files". The second is the chunks collection, which contains
    15  // chunks of files. This collection is named "<bucket name>.chunks".
    16  //
    17  // # Uploading a File
    18  //
    19  // Files can be uploaded in two ways:
    20  //
    21  //  1. OpenUploadStream/OpenUploadStreamWithID - These methods return an UploadStream instance. UploadStream
    22  //     implements the io.Writer interface and the Write() method can be used to upload a file to the database.
    23  //
    24  //  2. UploadFromStream/UploadFromStreamWithID - These methods take an io.Reader, which represents the file to
    25  //     upload. They internally create a new UploadStream and close it once the operation is complete.
    26  //
    27  // # Downloading a File
    28  //
    29  // Similar to uploads, files can be downloaded in two ways:
    30  //
    31  //  1. OpenDownloadStream/OpenDownloadStreamByName - These methods return a DownloadStream instance. DownloadStream
    32  //     implements the io.Reader interface. A file can be read either using the Read() method or any standard library
    33  //     methods that reads from an io.Reader such as io.Copy.
    34  //
    35  //  2. DownloadToStream/DownloadToStreamByName - These methods take an io.Writer, which represents the download
    36  //     destination. They internally create a new DownloadStream and close it once the operation is complete.
    37  package gridfs
    38  

View as plain text