Loading tools/max.sh +5 −3 Original line number Diff line number Diff line Loading @@ -180,10 +180,11 @@ nakala_upload_file(){ -H "Content-Type: multipart/form-data" \ -F "file=@$file;type=application/xml") response=(${response[@]}) # convert to array code=${response[-1]} # get last element (last line) body=${response[@]::${#response[@]}-1} # get all elements except last code=${response[-1]} # http code body=${response[@]::${#response[@]}-1} # response body sha1=$(echo $body | sed -E 's/.*"sha1":"?([^,"]*)"?.*/\1/') echo -e 'code = '$code #todo : manage other http codes case $code in '401') echo 'Upload impossible du fichier '$f', vérifiez votre clé API';return 1;; '201') nakala_add_file_to_collection $f $sha1 $collection_id $apikey;return 0;; Loading @@ -195,6 +196,7 @@ nakala_add_file_to_collection(){ sha1=$2 collection_id=$3 apikey=$4 #todo : read xpath from config title=$($BASEX_BIN "string(doc('$file')//*:teiHeader//*:titleStmt/*:title)") echo -e 'Ajout du fichier '$file' à la collection '$collection_id response=$(curl -s -X POST "https://apitest.nakala.fr/datas" \ Loading Loading
tools/max.sh +5 −3 Original line number Diff line number Diff line Loading @@ -180,10 +180,11 @@ nakala_upload_file(){ -H "Content-Type: multipart/form-data" \ -F "file=@$file;type=application/xml") response=(${response[@]}) # convert to array code=${response[-1]} # get last element (last line) body=${response[@]::${#response[@]}-1} # get all elements except last code=${response[-1]} # http code body=${response[@]::${#response[@]}-1} # response body sha1=$(echo $body | sed -E 's/.*"sha1":"?([^,"]*)"?.*/\1/') echo -e 'code = '$code #todo : manage other http codes case $code in '401') echo 'Upload impossible du fichier '$f', vérifiez votre clé API';return 1;; '201') nakala_add_file_to_collection $f $sha1 $collection_id $apikey;return 0;; Loading @@ -195,6 +196,7 @@ nakala_add_file_to_collection(){ sha1=$2 collection_id=$3 apikey=$4 #todo : read xpath from config title=$($BASEX_BIN "string(doc('$file')//*:teiHeader//*:titleStmt/*:title)") echo -e 'Ajout du fichier '$file' à la collection '$collection_id response=$(curl -s -X POST "https://apitest.nakala.fr/datas" \ Loading