Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,31 @@ jobs:

- name: Create Test File
run: |
echo "test" > testfile.txt
echo "test" > testfile1.txt
echo "test" > testfile2.txt

- name: Request Postman Echo POST Multipart
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
files: '{ "file": "${{ github.workspace }}/testfile1.txt" }'

- name: Request Postman Echo POST Multipart File Array
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
files: '{ "file": ["${{ github.workspace }}/testfile1.txt", "${{ github.workspace }}/testfile2.txt"] }'

- name: Request Postman Echo POST and persist response
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile.txt"
file: "${{ github.workspace }}/testfile1.txt"
responseFile: "${{ github.workspace }}/response.json"
- name: Output responseFile
run: |
Expand All @@ -148,14 +158,14 @@ jobs:
with:
url: 'https://postman-echo.com/post'
method: 'POST'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
files: '{ "file": "${{ github.workspace }}/testfile1.txt" }'

- name: Request Postman Echo POST single file
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile.txt"
file: "${{ github.workspace }}/testfile1.txt"

- name: Request Postman Echo POST URLEncoded string data
uses: ./
Expand Down
8 changes: 6 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26660,15 +26660,19 @@ const convertToJSON = (value) => {
*
* @returns {FormData}
*/
const convertToFormData = (data, files, convertPaths) => {
const convertToFormData = async (data, files, convertPaths) => {
const formData = new FormData();

for (const [key, value] of Object.entries(data)) {
formData.append(key, value);
}

for (const [key, value] of Object.entries(files)) {
formData.append(key, fs.createReadStream(value));
if (Array.isArray(value)) {
value.forEach(v => formData.append(key, fs.createReadStream(v)))
} else {
formData.append(key, fs.createReadStream(value));
}
}

return formData;
Expand Down
Loading