Skip to content

Commit

Permalink
Merge pull request #47 from lazy-electron-consulting/46-very-small-files
Browse files Browse the repository at this point in the history
allow very small files with PutFile
  • Loading branch information
tombuildsstuff authored Jan 4, 2021
2 parents e0da1ec + 5aac571 commit 9de4e97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 0 additions & 3 deletions storage/2019-12-12/file/files/range_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ func (client Client) PutByteRange(ctx context.Context, accountName, shareName, p
if expectedBytes != int64(actualBytes) {
return result, validation.NewError("files.Client", "PutByteRange", fmt.Sprintf("The specified byte-range (%d) didn't match the content size (%d).", expectedBytes, actualBytes))
}
if expectedBytes < (4 * 1024) {
return result, validation.NewError("files.Client", "PutByteRange", "Specified Byte Range must be at least 4KB.")
}

if expectedBytes > (4 * 1024 * 1024) {
return result, validation.NewError("files.Client", "PutByteRange", "Specified Byte Range must be at most 4MB.")
Expand Down
5 changes: 5 additions & 0 deletions storage/2019-12-12/file/files/range_put_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func TestPutLargeFile(t *testing.T) {
testPutFile(t, "blank-large-file.dmg", "application/x-apple-diskimage")
}

func TestPutVerySmallFile(t *testing.T) {
// the purpose of this test is to ensure that a very small file (< 4KB) is a single chunk
testPutFile(t, "very-small.json", "application/json")
}

func testPutFile(t *testing.T, fileName string, contentType string) {
client, err := testhelpers.Build(t)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions storage/testdata/very-small.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"key": "value"
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

const Number = "v0.15.0"
const Number = "v0.15.1"

0 comments on commit 9de4e97

Please sign in to comment.