[CSHARP-1484] Support GridFSDownloadStream CopyTo and CopyToAsync methods Created: 20/Nov/15 Updated: 19/Apr/18 Resolved: 02/Dec/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | GridFS |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | 2.2 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Lee Blundell | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
C#, .NET 4.5, Visual Studio 2015, Windows 10 |
||
| Attachments: |
|
| Description |
|
Given a GridFSBucket implementation when calling the OpenDownloadStreamAsync method a GridFSDownloadStream is returned. The stream returned from the API does not allow us to copy it. When using the CopyToAsync method, a NotImplementedException is thrown, and a NotSupportedException is thrown when using the CopyTo and Read methods. ReadAsync seems to be the only method that works correctly. I have attached a .NET sample to show the scenario. |
| Comments |
| Comment by Githook User [ 02/Dec/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Robert Stam [ 30/Nov/15 ] |
|
In 2.1.2 we will support CopyToAsync but not CopyTo since 2.1.x is still async-only. |
| Comment by Githook User [ 30/Nov/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Robert Stam [ 22/Nov/15 ] |
|
It looks like the base Stream class already implements CopyTo and CopyToAsync so probably all we need to do is not override them and let the base class handle them. Although we might get better performance overriding them in order to read and write the data in some multiple of the GridFS chunk size. |
| Comment by Robert Stam [ 22/Nov/15 ] |
|
The 2.1 version of the .NET driver is an async-only driver, which is why the Read method is not supported in 2.1. The 2.2 version of the .NET driver adds sync versions of all the async methods, so starting with the 2.2 version Read will be supported as well. However, as you have correctly pointed out, we need to implement the CopyTo and CopyToAsync methods. I have changed the summary to reflect this. |