-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: sample image data not showing #6805
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a6172e9
fix: sample image data not showing
vanpho93 149faac
Merge branch 'trunk' into fix/sample-image-data-not-showing
vanpho93 ecbd5c0
fix: request range case
vanpho93 6a506d8
feat: add unit test for requestRange file
vanpho93 7bcdb33
fix: lint fail on requestRange file
vanpho93 b0d3bbf
feat: update GridFSStore file
vanpho93 64f438b
fix: unit test fail on requestRange file
vanpho93 106eaac
fix: update expect value for requestRange test
vanpho93 74b0cdd
feat: check content start-end for requestRange
vanpho93 7f450c8
feat: add changeset for file-collections-sa-gridfs plugin
vanpho93 3c01340
Merge branch 'trunk' into fix/sample-image-data-not-showing
brent-hoover 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@reactioncommerce/api-plugin-sample-data": minor | ||
"@reactioncommerce/file-collections": minor | ||
"@reactioncommerce/file-collections-sa-gridfs": minor | ||
--- | ||
|
||
fix: sample image data not showing |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
93 changes: 93 additions & 0 deletions
93
packages/file-collections/src/node/getFileDownloadHandler/requestRange.test.js
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import requestRange from "./requestRange.js"; | ||
|
||
test("should return default setting when range header is not present", () => { | ||
const headers = {}; | ||
const fileSize = 100; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
end: 99, | ||
len: 100, | ||
partial: false, | ||
size: 100, | ||
start: 0, | ||
unit: "bytes" | ||
}); | ||
}); | ||
|
||
test("should return correct range when range header is present", () => { | ||
const headers = { range: "bytes=0-999" }; | ||
const fileSize = 1000; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
end: 999, | ||
len: 1000, | ||
partial: false, | ||
size: 1000, | ||
start: 0, | ||
unit: "bytes" | ||
}); | ||
}); | ||
|
||
test("should return the correct range when the range header request first half part of the file", () => { | ||
const headers = { range: "bytes=0-499" }; | ||
const fileSize = 1000; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
end: 499, | ||
len: 500, | ||
partial: true, | ||
size: 1000, | ||
start: 0, | ||
unit: "bytes" | ||
}); | ||
}); | ||
|
||
test("should return error when range header is present but file size is not", () => { | ||
const headers = { range: "bytes=0-10" }; | ||
const fileSize = null; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
errorCode: 416, | ||
errorMessage: "Requested Range Not Satisfiable (Unknown File Size)" | ||
}); | ||
}); | ||
|
||
test("should return error when range header is present but invalid", () => { | ||
const headers = { range: "bytes" }; | ||
const fileSize = 100; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
errorCode: 416, | ||
errorMessage: "Requested Range Unit Not Satisfiable" | ||
}); | ||
}); | ||
|
||
test('should return error when range header is present but unit is not a "bytes"', () => { | ||
const headers = { range: "k_bytes=0-10" }; | ||
const fileSize = 100; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
errorCode: 416, | ||
errorMessage: "Requested Range Unit Not Satisfiable" | ||
}); | ||
}); | ||
|
||
test("should return error when range header is present but start is greater than end", () => { | ||
const headers = { range: "bytes=10-9" }; | ||
const fileSize = 100; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
errorCode: 416, | ||
errorMessage: "Requested Range Not Satisfiable" | ||
}); | ||
}); | ||
|
||
test("should return error when range header is present but end is greater than file size", () => { | ||
const headers = { range: "bytes=0-1000" }; | ||
const fileSize = 100; | ||
const result = requestRange(headers, fileSize); | ||
expect(result).toEqual({ | ||
errorCode: 416, | ||
errorMessage: "Requested Range Not Satisfiable" | ||
}); | ||
}); |
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.
Uh oh!
There was an error while loading. Please reload this page.