通过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>
块。
虽然您可能认为可以将各个文件的uploadParams
参数作为同一作业的一部分进行更改,但情况并非如此。 对整个作业使用相同的uploadParams
参数。
新上载作业的初始POST请求应指定jobName
参数,最好使用唯一的作业名称来简化后续作业状态轮询和作业日志查询。 对于同一上载作业的其他POST请求,应使用从初始请求返回的jobHandle
值指定jobHandle
参数而不是jobName
。
上载作业的最终POST请求应将endJob
参数设置为true,以便将来不会为此作业发布任何文件。 反过来,这允许作业在摄取所有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>