【问题标题】:Bluemix document conversion service - how to convert multiple documents [duplicate]Bluemix 文档转换服务 - 如何转换多个文档 [重复]
【发布时间】:2015-11-25 15:46:11
【问题描述】:

我的目标是 JSON 格式的单个文档文件,它来自 50-100 个 MS Word 或 PDF 文档。

有没有办法为“convert_document”命令提供多个文档?我尝试使用 curl 来提供多个 .pdf 或 *.doc 文件,如下所示:

 curl -u
  "username":"password" 
  -F "config={\"conversion_target\":\"ANSWER_UNITS\"};type=application/json" 
  -F "file=@\*.doc;type=application/msword" -X POST
 "https://gateway.watsonplatform.net/document-conversion-experimental/api/v1/convert_document"

不幸的是,这给了我一个错误:curl: (26) couldn't open file "*.doc" 我也试过-F "file=@file1.doc,file2.doc,file3.doc",但这也会出错。

【问题讨论】:

    标签: curl ibm-cloud ibm-watson document-conversion


    【解决方案1】:

    文档转换服务一次只接受一个文件,但您可以多次调用它并连接结果。

     #!/bin/bash
     USERNAME="<service-username>"
     PASSWORD="<service-password>"
     URL="https://gateway.watsonplatform.net/document-conversion-experimental/api/v1/convert_document"
     DIRECTORY="/path/to/documents"
     for doc in *.doc
     do
         echo "Converting - $doc"
         curl -u "$USERNAME:$PASSWORD" \
         -F 'config={"conversion_target":"ANSWER_UNITS"};type=application/json' \
         -F "file=@$doc;type=application/pdf" "$URL"
     done
    

    【讨论】:

      猜你喜欢
      • 2016-10-02
      • 2023-04-02
      • 2021-02-21
      • 2011-10-04
      • 2013-07-22
      • 2012-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多