透過HTTP POST將資產上傳到UploadFile Servlet uploading-assets-by-way-of-http-posts-to-the-uploadfile-servlet
將資產上傳到Dynamic Media Classic涉及一個或多個HTTPPOST請求,這些請求會設定協調與上傳檔案關聯的所有記錄活動的工作。
使用下列URL存取UploadFile Servlet:
https://<server>/scene7/UploadFile
存取Dynamic Media地區的URL
上載工作的工作流程 section-873625b9512f477c992f5cdd77267094
上載工作包含一或多個HTTP POST,這些HTTP POST使用通用jobHandle
將處理關聯到相同工作。 每個請求都經過multipart/form-data
編碼,由下清單單元件組成:
auth
file params
uploadPostParams/fileName
引數,該引數將用作IPS中的目標檔案名稱。uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)companyHandle
xsd:string
uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)jobName
xsd:string
jobName
或jobHandle
。 上載工作的名稱。uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)jobHandle
xsd:string
jobName
或jobHandle
。 處理在先前請求中啟動的上傳工作。uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)locale
xsd:string
uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)description
xsd:string
uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)destFolder
xsd:string
uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)fileName
xsd:string
uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)endJob
xsd:boolean
uploadParams
(必要。 XML uploadParams
檔案指定上傳引數)uploadParams
types:UploadPostJob
uploadParams
並使用現有工作上傳引數。 檢視UploadPostJob在<uploadPostParams>
區塊中是指定處理所包含檔案的<uploadParams>
區塊。
請參閱UploadPostJob。
雖然您可能會假設uploadParams
引數可以隨著相同工作針對個別檔案變更,但情況並非如此。 在整個工作中使用相同的uploadParams
引數。
新上傳工作的初始POST請求應指定jobName
引數,最好使用唯一的工作名稱來簡化後續工作狀態輪詢和工作記錄查詢。 相同上載工作的其他POST要求應使用從初始要求傳回的jobHandle
值,指定jobHandle
引數,而非jobName
。
上載工作的最終POST要求應該將endJob
引數設定為true,如此此工作未來就不會對檔案進行POST。 反過來,這可讓工作在擷取所有POSTed檔案後立即完成。 否則,如果未在30分鐘內收到其他POST請求,則作業會逾時。
uploadpost回應 section-421df5cc04d44e23a464059aad86d64e
對於成功的POST要求,回應本文是XML uploadPostReturn
檔案,如下列的XSD所指定:
<element name="uploadPostReturn">
<complexType>
<sequence>
<element name="jobHandle" type="xsd:string"/>
</sequence>
</complexType>
</element>
針對相同工作的任何後續POST要求,傳回的jobHandle
會傳入uploadPostParams
/ jobHandle
引數。 您也可以用它來輪詢具有getActiveJobs
作業的工作狀態,或查詢具有getJobLogDetails
作業的工作記錄檔。
如果處理POST要求時發生錯誤,回應主體會包含錯誤中說明的其中一個API錯誤型別。
範例POST請求 section-810fe32abdb9426ba0fea488dffadd1e
POST /scene7/UploadFile HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost
Content-Length: 362630
Content-Type: multipart/form-data; boundary=O9-ba7tieRtqA4QRSaVk-eDq6658SPrYfvUcJ
--O9-ba7tieRtqA4QRSaVk-eDq6658SPrYfvUcJ
Content-Disposition: form-data; name="auth"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
<authHeader xmlns="http://www.scene7.com/IpsApi/xsd/2014-04-03">
<user>sampleuser@test.com</user>
<password>*</password>
<locale>en-US</locale>
<appName>MyUploadServletTest</appName>
<appVersion>1.0</appVersion>
<faultHttpStatusCode>200</faultHttpStatusCode>
</authHeader>
--O9-ba7tieRtqA4QRSaVk-eDq6658SPrYfvUcJ
Content-Disposition: form-data; name="uploadParams"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
<uploadPostParam xmlns="http://www.scene7.com/IpsApi/xsd/2014-04-03">
<companyHandle>c|2101</companyHandle>
<jobName>uploadFileServlet-1376682217351</jobName>
<uploadParams>
<overwrite>true</overwrite>
<readyForPublish>true</readyForPublish>
<preservePublishState>true</preservePublishState>
<createMask>true</createMask>
<preserveCrop>true</preserveCrop>
<manualCropOptions>
<left>500</left>
<right>500</right>
<top>500</top>
<bottom>500</bottom>
</manualCropOptions>
<photoshopOptions>
<process>MaintainLayers</process>
<layerOptions>
<layerNaming>AppendNumber</layerNaming>
<anchor>Northwest</anchor>
<createTemplate>true</createTemplate>
<extractText>true</extractText>
<extendLayers>false</extendLayers>
</layerOptions>
</photoshopOptions>
<emailSetting>None</emailSetting>
</uploadParams>
</uploadPostParam>
--O9-ba7tieRtqA4QRSaVk-eDq6658SPrYfvUcJ--
Content-Disposition: form-data; name="file1"; filename="ApiTestCo1/UploadFileServlet1376682217351//1376682217351-1.jpg"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary
<file bytes ... >
--O9-ba7tieRtqA4QRSaVk-eDq6658SPrYfvUcJ--
Content-Disposition: form-data; name="file2"; filename="ApiTestCo1/UploadFileServlet1376682217351//1376682217351-2.jpg"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary
<file bytes ... >
--O9-ba7tieRtqA4QRSaVk-eDq6658SPrYfvUcJ--
範例POST回應 — 成功 section-0d515ba14c454ed0b5196ac8d1bb156e
HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Content-Length: 204
Date: Mon, 25 Jul 2016 19:43:38 GMT
Server: Unknown
'1.0' encoding='UTF-8'?><uploadPostReturn xmlns="http://www.scene7.com/IpsApi/xsd/2014-04-03">
<jobHandle>j|2101||uploadFileServlet-1376682217351|54091</jobHandle>
</uploadPostReturn>
範例POST回應 — 錯誤 section-efc32bb371554982858b8690b05090ec
HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Content-Length: 210
Date: Mon, 25 Jul 2016 19:43:38 GMT
Server: Unknown
<?xml version='1.0' encoding='UTF-8'?><tns:authenticationFault xmlns:tns="http://www.scene7.com/IpsApi/xsd"><tns:code>10001</tns:code><tns:reason>Invalid username/password</tns:reason></tns:authenticationFault>