Skip to content

Commit ab4abaa

Browse files
authored
Merge pull request #403 from bakaphp/hotfix-message-file-upload
hotfix: updload files
2 parents 26263e0 + 63f0a4b commit ab4abaa

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.30.6",
2+
"version": "0.30.7",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

Diff for: src/modules/messages/index.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,16 @@ export class Messages {
106106
formData.append('map', JSON.stringify({ '0': ['variables.input.files'] }));
107107
formData.append('0', file, file.name);
108108

109-
// The Authorization header should be added by the interceptor
110-
// that was set up in the constructor
111-
const response = await this.axiosClient.post('', formData);
109+
// Get the auth token from localStorage
110+
const authToken = localStorage.getItem("token") || null;
111+
112+
// Use inline config with Content-Type and Authorization if available
113+
const response = await this.axiosClient.post('', formData, {
114+
headers: {
115+
'Content-Type': 'multipart/form-data',
116+
...(authToken && { 'Authorization': `Bearer ${authToken}` })
117+
},
118+
});
112119

113120
return response;
114121
}

0 commit comments

Comments
 (0)