Important bug fix for posting form data. The headers are case sensitive. Changed them all to Content-Type.
This commit is contained in:
@@ -33,7 +33,7 @@ let ae_api_init: key_val = {
|
||||
|
||||
let ae_api_headers: key_val = {};
|
||||
ae_api_headers['Access-Control-Allow-Origin'] = '*';
|
||||
ae_api_headers['content-type'] = 'application/json';
|
||||
ae_api_headers['Content-Type'] = 'application/json';
|
||||
ae_api_headers['x-aether-api-key'] = ae_api_init.api_secret_key;
|
||||
ae_api_headers['x-aether-api-token'] = 'fake-temp-token';
|
||||
ae_api_headers['x-aether-api-expire-on'] = '';
|
||||
|
||||
@@ -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...
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
// *** Import Svelte specific
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
// *** Import other supporting libraries
|
||||
import {
|
||||
@@ -141,7 +142,8 @@ function verify_journal_passcode() {
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// $journals_sess.show__modal_new__journal_entry_obj = true;
|
||||
// $journals_sess.show__modal_new__journal_entry_obj = true
|
||||
// log_lvl = 3;
|
||||
|
||||
let data_kv = {
|
||||
category_code: null,
|
||||
|
||||
Reference in New Issue
Block a user