Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
1.0.4
-
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: []