Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1232

downloadStream result "nil"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Community Answered
    • Affects Version/s: 1.0.4
    • Fix Version/s: None
    • Component/s: GridFS
    • Labels:
      None

      Description

      var dodata []byte
      data := []byte("abc")
      uploadStream, err := buck.OpenUploadStream(
      "test.txt",
      )
      if err != nil {
      log.Println(err)
      log.Fatalln("Error opening uploadStream")
      }
      defer uploadStream.Close()
      fileSize, err := uploadStream.Write(data)
      if err != nil {
      log.Fatalln("Error writing uploadStream")
      }
      fileID := uploadStream.FileID
      fmt.Fprintf(w, "Write file to DB was succesful, File size: %d", fileSize)
      fmt.Fprintf(w, ", FileID: %d", fileID)
       
      downloadStream, err := buck.OpenDownloadStreamByName("test.txt")
      if err != nil {
      log.Fatalln(err)
      }
      defer downloadStream.Close()
      downSize, err := downloadStream.Read(dodata)
      if err != nil {
      log.Fatalln(err)
      }
      fmt.Fprintf(w, "Download file from DB was succesful, File size: %d", downSize)
      fmt.Fprintf(w, " Content: %d", dodata)
      


      Hello mongoDB Team
      I have an issue with golang driver and mongoDB. I want to download files from gridfs with downloadStream. Upload wasn't a problem,but if I try to download as you see in the code above, i will get the result like below .But it wasn't successful, because my log.Printf shows me nil.

      Write file to DB was succesful, File size: 3, FileID: [93 82 190 120 106 41 138 138 124 134 194 179]Download file from DB was succesful, File size: 0 Content: []


        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: