Skip to content
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

The implementation for custom saving is too redundant #6

Open
jsakamotoIGJP opened this issue Dec 28, 2022 · 0 comments
Open

The implementation for custom saving is too redundant #6

jsakamotoIGJP opened this issue Dec 28, 2022 · 0 comments

Comments

@jsakamotoIGJP
Copy link
Owner

https://github.dev/jsakamotoIGJP/Documentation/blob/6bed33b86ea21450fd2c47c4cd2b05037fc0aa73/docs/web/saving-dashboards.md#L252-L262

  • It will be better to use the "Declarative Using".
  • It will be better to copy from the request body stream to the FileStream directly without a byte[] buffer.

From:

    byte[] bytes;
    using (var ms = new MemoryStream())
    {
        await request.Body.CopyToAsync(ms);
        bytes = ms.ToArray();
    }

    using (var stream = File.Open(filePath, FileMode.Open))
    {
        stream.Write(bytes, 0, bytes.Length);
    }

To:

    using var stream = File.Open(filePath, FileMode.Open);
    await request.Body.CopyToAsync(stream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant