This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 344
Added the ability to upload files larger than 4MB #2180
Merged
+51
−19
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c8d31c4
Bug fix in BufferWriter
KrzysztofCwalina 8ee6979
Merge branch 'master' of https://github.com/dotnet/corefxlab
KrzysztofCwalina 33da66f
Merge branch 'master' of https://github.com/dotnet/corefxlab
KrzysztofCwalina ee23d6b
Merge branch 'master' of https://github.com/dotnet/corefxlab
KrzysztofCwalina 40bec88
AzCopyCore: Added the ability to upload files larger than 4MB
KrzysztofCwalina 474d53f
PR review feedback
KrzysztofCwalina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ public struct PutRangeRequest : IStorageRequest | |
|
||
public PutRangeRequest(string filePath, Stream fileContent, long offset, int length) | ||
{ | ||
if (offset < 0) throw new ArgumentOutOfRangeException(nameof(offset)); | ||
if (offset < 0 || offset > fileContent.Length - length) throw new ArgumentOutOfRangeException(nameof(offset)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. What about the case when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AORE will be thrown. fileContent.Length - length will be negative and will be < offset (which has to be positive at the time of this check) |
||
if (length < 1) throw new ArgumentOutOfRangeException(nameof(length)); | ||
|
||
_filePath = filePath; | ||
|
@@ -139,7 +139,7 @@ class Writer : StorageRequestWriter<PutRangeRequest> | |
|
||
protected override async Task WriteBody(PipeWriter writer, PutRangeRequest arguments) | ||
{ | ||
var stream = arguments._fileContent; | ||
Stream stream = arguments._fileContent; | ||
stream.Seek(arguments._offset, SeekOrigin.Begin); | ||
await writer.WriteAsync(stream, arguments._length); | ||
} | ||
|
@@ -150,8 +150,8 @@ protected override void WriteXmsHeaders(ref BufferWriter writer, ref PutRangeReq | |
writer.WriteHeader("x-ms-date", Time, 'R'); | ||
// TODO (pri 3): this allocation should be eliminated | ||
|
||
var start = arguments._offset; | ||
var end = start + arguments._length - 1; | ||
long start = arguments._offset; | ||
long end = start + arguments._length - 1; | ||
writer.WriteHeader("x-ms-range", $"bytes={start}-{end}"); | ||
writer.WriteHeader("x-ms-version", "2017-04-17"); | ||
writer.WriteHeader("x-ms-write", "update"); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't think this Debug.Assert is necessary, given the loop condition is already stronger. Maybe a better option would be to add a Debug.Assert after the loop exits, if we know that bytesLeft should never be negative and if that signals a coding bug:
Debug.Assert(bytesLeft == 0);
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.
The assert ensures bytesLeft is no negative