我创建了一个 Java Servlet 来访问 HCP 存储库。我已经使用 sap.ui.unified.FileUploader 将文件上传到上述存储库。它给了我以下错误:409 Conflict, {"exception":"constraint","message":"Mandatory property missing: cmis:name" }。
我使用以下代码使用 fileuploader 将数据作为表单提交:
<upload:FileUploader id="fileUploader" uplaodStart="handleUploadStart" uploadProgress="handleUploadProgress" uploadComplete="handleUploadComplete">
<upload:parameters>
<upload:FileUploaderParameter name="cmisaction" value="createDocument"></upload:FileUploaderParameter>
<upload:FileUploaderParameter name="propertyId[0]" value="cmis:objectTypeId"></upload:FileUploaderParameter>
<upload:FileUploaderParameter name="propertyValue[0]" value="cmis:document"></upload:FileUploaderParameter>
<upload:FileUploaderParameter name="propertyId[1]" value="cmis:name"></upload:FileUploaderParameter>
<upload:FileUploaderParameter name="propertyValue[1]" id="cmisname"></upload:FileUploaderParameter>
</upload:parameters>
</upload:FileUploader>
<Button text="Upload File" press="handleUploadPress"/>
控制器中的代码如下:
handleUploadPress: function(oEvent) {
debugger;
var oFileUploader = this.getView().byId("fileUploader");
var repoid="94hjinnfsai8opwroiwlnnsa";
var file = jQuery.sap.domById(oFileUploader.getId()+"-fu").files[0];
this.getView().byId("cmisname").setValue(file.name);
oFileUploader.setUploadUrl("/destinations/destinationName/json/"+repoid+"/root");
oFileUploader.setFileType("multipart/form-data");
oFileUploader.upload();
}
我在 fileuploader 的参数聚合中使用 cmis:name 参数,但有时它可以工作,有时它会给出上述错误。但是,文档中提供的 html5 表单可以完美运行。因此,我使用了 fileuploader 来充当表单。html5代码如下:
<form action="/destinations/destinationName/json/c4hjinnfsai8opwroiwlnnsa/root"
enctype="multipart/form-data" method="post">
<p>
Please specify a file:<br> <input type="file" id="filename"
onchange="setFilename()" name="datafile" size="40">
</p>
<div>
<input type="submit" value="Upload">
<input name="cmisaction" type="hidden" value="createDocument"/>
<input name="propertyId[0]" type="hidden" value="cmis:objectTypeId"/>
<input name="propertyValue[0]" type="hidden" value="cmis:document"/>
<input name="propertyId[1]" type="hidden" value="cmis:name"/>
<input name="propertyValue[1]" type="hidden" id="cmisname"/>
</div>
</form>
请帮忙。