Important bug fix for posting form data. The headers are case sensitive. Changed them all to Content-Type.
This commit is contained in:
@@ -103,7 +103,10 @@ async function handle_submit_form_files(event) {
|
||||
|
||||
|
||||
async function handle_input_upload_files(input_upload_files, task_id) {
|
||||
console.log('*** handle_input_upload_files() ***');
|
||||
log_lvl = 2;
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_input_upload_files() *** task_id = ${task_id}`);
|
||||
}
|
||||
|
||||
const form_data = new FormData();
|
||||
|
||||
@@ -126,26 +129,31 @@ async function handle_input_upload_files(input_upload_files, task_id) {
|
||||
|
||||
let endpoint = '/hosted_file/upload_files';
|
||||
|
||||
console.log(form_data);
|
||||
// console.log(form_data);
|
||||
|
||||
params = null;
|
||||
|
||||
// Uncomment and the post_promise is not seen by the "await" below
|
||||
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
|
||||
// Uncomment so that the post_promise is not seen by the "await" below
|
||||
ae_promises.upload__hosted_file_obj = api.post_object({
|
||||
ae_promises.upload__hosted_file_obj = await api.post_object({
|
||||
api_cfg: $ae_api,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
// params: params,
|
||||
form_data: form_data,
|
||||
task_id: task_id,
|
||||
log_lvl: log_lvl
|
||||
log_lvl: log_lvl,
|
||||
retry_count: 1,
|
||||
})
|
||||
.then(async function (result) {
|
||||
// console.log('HERE!!', result);
|
||||
|
||||
// WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
|
||||
// NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
|
||||
let x = 0;
|
||||
console.log(result[x]);
|
||||
if (log_lvl) {
|
||||
console.log(`result = `, result[x]);
|
||||
}
|
||||
let hosted_file_obj = result[x];
|
||||
|
||||
let hosted_file_id = hosted_file_obj.hosted_file_id_random;
|
||||
@@ -157,7 +165,9 @@ async function handle_input_upload_files(input_upload_files, task_id) {
|
||||
event_file_data['filename'] = hosted_file_obj.filename;
|
||||
event_file_data['extension'] = hosted_file_obj.extension;
|
||||
event_file_data['enable'] = true;
|
||||
console.log(event_file_data);
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_data = `, event_file_data);
|
||||
}
|
||||
|
||||
// $events_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user