gpt4 book ai didi

file-upload - 使用 RIDC 将带有 ADF 输入文件的文件上传到 UCM 文件夹

转载 作者:行者123 更新时间:2023-12-02 17:41:29 30 4
gpt4 key购买 nike

我正在使用 JDeveloper。在 ADF Fusion Web 应用程序中,我有一个输入文件控件和一个发送按钮,该按钮调用 bean 方法将文件上传到 UCM。如果我的文件位于我的计算机上,比如说“/home/user/myfile.txt”,它就像一个魅力。如果我尝试使用输入文件,则在不先将此文件保存到磁盘然后上传此文件的情况下,我看不到如何将文件上传到 UCM。在我看来,这种做法是不推荐的。

这是我迄今为止能够上传来自服务器工作站的文件的代码:

// RETRIEVE THE DESTINATION PATH
DataBinder binder = idcClient.createBinder();
binder.putLocal("IdcService", "COLLECTION_INFO");
binder.putLocal("hasCollectionPath", "true");
binder.putLocal("dCollectionPath", "/Contribution Folders/PDD"); // The path you are looking for
DataBinder searchFolder = idcClient.sendRequest(idcContext, binder).getResponseAsBinder();

binder = idcClient.createBinder();
binder.putLocal ("IdcService", "CHECKIN_NEW");
binder.putLocal ("dDocAuthor", "weblogic");
binder.putLocal ("dDocTitle", "myimage2.jpg");
binder.putLocal ("dDocName", "myimage2.jpg");
binder.putLocal ("dDocType", "Document");
binder.putLocal("xCollectionID", searchFolder.getLocal("dCollectionID"));
binder.putLocal ("dSecurityGroup", "Public");
binder.putLocal ("dDocAccount:", "");
binder.putLocal ("xComments", "My comment");
binder.addFile ("primaryFile", new File("/home/oracle/myimage.jpg"));

// check in the file
ServiceResponse response = idcClient.sendRequest (idcContext, binder);

如果您有任何建议,我将不胜感激。谢谢大家!

<小时/>

解决方案如下:

        UploadedFile uf = (UploadedFile) inputFile1.getValue();

DataBinder binder = idcClient.createBinder();
binder.putLocal ("IdcService", "CHECKIN_NEW");
binder.putLocal ("dDocAuthor", "weblogic"); // if user is admin, can specify other user
binder.putLocal ("dDocTitle", uf.getFilename());
binder.putLocal ("dDocName", uf.getFilename());
binder.putLocal ("dDocType", "DigitalMedia");
binder.putLocal("xCollectionID", getFolderCollectionId("/Contribution Folders/PDD")); // parent's folder
binder.putLocal ("dSecurityGroup", "Public");
binder.putLocal ("dDocAccount:", "");
binder.putLocal ("xComments", "Montreal comment");
binder.putLocal ("xWCTags", "Montreal");

binder.addFile ("primaryFile", new TransferFile(uf.getInputStream(), uf.getFilename(), getByteLenght(uf.getInputStream())));

ServiceResponse response = idcClient.sendRequest (idcContext, binder);

最佳答案

您已经自己找到了解决方案,所以我只想提一下,这里应该使用其他方便的 UploadFile 方法。

getFilename(); //you've got this
getLength(); //instead of getting byte length from stream
getContentType(); //available MIME

您的 getFolderCollectionId("/Contribution Folders/PDD")) 是否按预期工作?

另请记住,仅当文件大小小于 100KB 时才会将其存储在内存中,如果大于 100KB,则将其写入磁盘。每个请求限制为 2000KB。这些是默认值,可以在 servlet 上下文初始化参数中更改。

<context-param>
<!-- Maximum memory per request (in bytes) -->
<param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
<param-value>512000</param-value>
</context-param>
<context-param>
<!-- Maximum disk space per request (in bytes) -->
<param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>
<param-value>5120000</param-value>
</context-param>
<context-param>
<!-- directory to store temporary files -->
<param-name>oracle.adf.view.faces.UPLOAD_TEMP_DIR</param-name>
<param-value>/tmp/ADFUploads/</param-value>
</context-param>

<!-- This filter is always required by ADF; one of its functions is file upload. -->
<filter>
<filter-name>adfFaces</filter-name>
<filter-class>oracle.adf.view.faces.webapp.AdfFacesFilter</filter-class>
</filter>

关于file-upload - 使用 RIDC 将带有 ADF 输入文件的文件上传到 UCM 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13090067/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com