-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(proxy): file upload via multipart/form-data or application/octet-…
…stream (#2708) - fixing /proxy to allow file upload with `Content-Type: multipart/form-data` - adding support for uploading file in proxy with `Content-Type: application/octet-stream` - fixing node client to upload file via `nango.proxy()` ## Issue ticket number and link https://linear.app/nango/issue/NAN-1473/enable-file-upload-with-nango-proxy ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] I added observability, otherwise the reason is: - [ ] I added analytics, otherwise the reason is:
- Loading branch information
Showing
7 changed files
with
69 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Nango } from '../dist/index.js'; | ||
import fs from 'fs'; | ||
const args = process.argv.slice(2); | ||
|
||
const nango = new Nango({ host: 'http://localhost:3003', secretKey: args[0] }); | ||
|
||
const filePath = './test.pdf'; | ||
const fileName = filePath.split('/').pop(); | ||
const buffer = fs.readFileSync(filePath); | ||
|
||
nango | ||
.proxy({ | ||
providerConfigKey: 'unauthenticated', | ||
connectionId: 'u', | ||
baseUrlOverride: 'http://localhost:3009', | ||
method: 'POST', | ||
endpoint: '/upload/octet-stream', | ||
data: buffer, | ||
headers: { | ||
'Content-Type': 'application/octet-stream', | ||
'X-File-Name': fileName | ||
} | ||
}) | ||
.then((response) => { | ||
console.log(response?.data); | ||
}) | ||
.catch((err) => { | ||
console.log(err.response?.data || err.message); | ||
}); |
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
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