Align files_attributes in remote evaluation with structure of normal submission

This commit is contained in:
tobias.kantusch
2021-04-26 15:35:16 +02:00
committed by Sebastian Serth
parent 36cacc2330
commit 91a0e4a7d5
3 changed files with 13 additions and 13 deletions

View File

@@ -44,7 +44,7 @@ function get_file_attributes {
file_path="$(get_valid_file_path "${file_info%=*}")"
escaped_file_content="$(get_escaped_file_content "$file_path")"
file_id="${file_info##*=}"
echo "{\"file_id\": $file_id,\"content\": \"$escaped_file_content\"}"
echo "\"$2\": {\"file_id\": $file_id,\"content\": \"$escaped_file_content\"}"
}
function read_file_to_array {
@@ -63,13 +63,13 @@ validation_token="${file_array[0]}"
target_url="${file_array[1]}"
files_attributes="$(get_file_attributes "${file_array[2]}")"
files_attributes="$(get_file_attributes "${file_array[2]}" 0)"
for ((i = 3; i < ${#file_array[@]}; i++)); do
files_attributes+=", $(get_file_attributes "${file_array[i]}")"
files_attributes+=", $(get_file_attributes "${file_array[i]}" $((i-2)))"
done
post_data="{\"remote_evaluation\": {\"validation_token\": \"$validation_token\",\"files_attributes\": [$files_attributes]}}"
post_data="{\"remote_evaluation\": {\"validation_token\": \"$validation_token\",\"files_attributes\": {$files_attributes}}}"
curl -H 'Content-Type: application/json' --data "$(echo $post_data)" "$target_url"
echo