Commit 2afb7d22 authored by Frank Bergmann's avatar Frank Bergmann

- Fixed JSON return messages

parent 824cccfa
{'success': true, 'message': 'success', 'version': 'v1'}
{"success": true, "message": "success", "version": "v1"}
......@@ -15,6 +15,7 @@ ad_page_contract {
{ upload_comment "" }
{ title "" }
{ description "description" }
{ ignore_p 0 }
}
set user_id [ad_conn user_id]
......@@ -26,7 +27,7 @@ ns_log Notice "upload: project_id=$project_id, path=$path, upload_file=$upload_f
set max_bytes [parameter::get_from_package_key -package_key "file-storage" -parameter "MaximumFileSize"]
if {$n_bytes > $max_bytes } {
doc_return 507 "application/json" "{success: false, message: \"File is larger than the maximum size ($max_bytes bytes) allowed on this server\"}"
doc_return 507 "application/json" "{\"success\": false, \"message\": \"File is larger than the maximum size ($max_bytes bytes) allowed on this server\"}"
ad_script_abort
}
......@@ -34,7 +35,7 @@ ns_log Notice "upload: im_rest_fs_folder_for_path -object_id $project_id -path $
set folder_id [im_rest_fs_folder_for_path -object_id $project_id -path $path]
if {"" eq $folder_id} {
# Folder path not found
doc_return 400 "application/json" "{'success': false, 'message': 'Did not find folder ´[ns_quotehtml $path]´', 'data': {}}"
doc_return 400 "application/json" "{\"success\": false, \"message\": \"Did not find folder ´[ns_quotehtml $path]´\", \"data\": {}}"
ad_script_abort
}
......@@ -45,6 +46,11 @@ set mime_type [cr_filename_to_mime_type -create -- $upload_file]
set file_id [db_nextval "acs_object_id_seq"]
ns_log Notice "upload: folder_id=$folder_id, file_id=$file_id, mime_type=$mime_type"
# Just dry running?
if {$ignore_p} {
doc_return 200 "application/json" "{\"success\": true, \"message\": \"Request ignored.\", \"data\": {\"id\": $file_id}}"
ad_script_abort
}
set file_version_id [fs::add_file \
-name $upload_file \
......@@ -107,6 +113,6 @@ if {!$file_version_exists_p} {
file delete ${upload_file.tmpfile}
doc_return 200 "application/json" "{success: true, message: \"Upload successful.\", data: {id: $file_id}}"
doc_return 200 "application/json" "{\"success\": true, \"message\": \"Upload successful.\", \"data\": {\"id\": $file_id}}"
ad_script_abort
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment