Commit da526c6b authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

commentaires nakala sed and co

parent 1c8eab49
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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;;
@@ -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" \