@insignia-education/api-sdk-js 0.15.59 → 0.15.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Client.js +4 -1
- package/src/api/v1/Users.js +7 -5
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -93,8 +93,11 @@ export default class InsigniaClient {
|
|
|
93
93
|
if (this.#baseUrl.includes('ngrok')) headers['ngrok-skip-browser-warning'] = 'true';
|
|
94
94
|
const cookie = this.#cookieHeader();
|
|
95
95
|
if (cookie) headers.Cookie = cookie;
|
|
96
|
+
// POST, not PUT: PHP only parses multipart/form-data bodies into $_FILES for
|
|
97
|
+
// POST requests — a PUT with the exact same body leaves $_FILES empty and the
|
|
98
|
+
// raw body unread, so `$request->file(...)` is always null server-side.
|
|
96
99
|
const response = await fetch(`${this.#baseUrl}${path}`, {
|
|
97
|
-
method: '
|
|
100
|
+
method: 'POST', headers, credentials: 'include', body: formData,
|
|
98
101
|
});
|
|
99
102
|
this.#storeCookies(response);
|
|
100
103
|
if (!response.ok) {
|
package/src/api/v1/Users.js
CHANGED
|
@@ -58,12 +58,14 @@ export default class Users {
|
|
|
58
58
|
edit: (id, data) => client.patch(`${base}/${id}`, data),
|
|
59
59
|
delete: (id) => client.del(`${base}/${id}`),
|
|
60
60
|
/**
|
|
61
|
-
* Upload the
|
|
62
|
-
* document_upload
|
|
63
|
-
*
|
|
61
|
+
* Upload the file a student attaches as their answer to a
|
|
62
|
+
* document_upload (PDF) or audio_answer (recording) question
|
|
63
|
+
* (formData must contain `file`) — the kind is derived server-side
|
|
64
|
+
* from the question's own flags. The server derives the storage
|
|
65
|
+
* path/filename — nothing else to pass.
|
|
64
66
|
*/
|
|
65
|
-
|
|
66
|
-
client.upload(`${base}/${quizId}/
|
|
67
|
+
uploadQuestionFile: (quizId, questionId, formData) =>
|
|
68
|
+
client.upload(`${base}/${quizId}/questions/${questionId}/file`, formData),
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
|