-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add downloader example #1689
Add downloader example #1689
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Minor various formatting fixes in feedback
if (message.Metadata != null) | ||
{ | ||
Console.WriteLine("Saving metadata to file"); | ||
string metadata = message.Metadata.ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string metadata = message.Metadata.ToString(); | |
var metadata = message.Metadata.ToString(); |
while (await call.ResponseStream.MoveNext()) | ||
{ | ||
var message = call.ResponseStream.Current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while (await call.ResponseStream.MoveNext()) | |
{ | |
var message = call.ResponseStream.Current; | |
await foreach (var message in call.ResponseStream.ReadAllAsync()) | |
{ |
Console.WriteLine("\nFiles were saved in: " + downloadIdPath); | ||
Console.WriteLine("\nPress any key to exit..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of \n here? IMO use Console.WriteLine()
to add additional line breaks if desired.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
}); | ||
|
||
var buffer = new byte[ChunkSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var buffer = new byte[ChunkSize]; | |
var buffer = new byte[ChunkSize]; |
await responseStream.WriteAsync(new DownloadFileResponse { | ||
Metadata = new FileMetadata | ||
{ | ||
FileName = filename | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await responseStream.WriteAsync(new DownloadFileResponse { | |
Metadata = new FileMetadata | |
{ | |
FileName = filename | |
} | |
}); | |
await responseStream.WriteAsync(new DownloadFileResponse | |
{ | |
Metadata = new FileMetadata { FileName = filename } | |
}); |
_logger.LogInformation("Sending data chunk of {numBytesRead} bytes", numBytesRead); | ||
await responseStream.WriteAsync(new DownloadFileResponse | ||
{ | ||
Data = UnsafeByteOperations.UnsafeWrap(buffer.AsMemory(0, numBytesRead)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data = UnsafeByteOperations.UnsafeWrap(buffer.AsMemory(0, numBytesRead)) | |
Data = UnsafeByteOperations.UnsafeWrap(buffer.AsMemory(0, numBytesRead)) |
|
||
while (true) | ||
{ | ||
int numBytesRead = await fileStream.ReadAsync(buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int numBytesRead = await fileStream.ReadAsync(buffer); | |
var numBytesRead = await fileStream.ReadAsync(buffer); |
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure how to edit this pull request without tons of commits. |
Lots of commits are fine. Squash merging is simple. |
Hi,
finished this example,
let me know if there's something to improve here :)
( Closes #1680 )