Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java CMIS Alfresco-以编程方式更新文档mime类型和文件扩展名_Java_Alfresco_Mime Types_Cmis - Fatal编程技术网

Java CMIS Alfresco-以编程方式更新文档mime类型和文件扩展名

Java CMIS Alfresco-以编程方式更新文档mime类型和文件扩展名,java,alfresco,mime-types,cmis,Java,Alfresco,Mime Types,Cmis,我有一些文档最初作为.doc文件上传到alfresco share,其mimetype为Microsoft Word(应用程序/msword) 现在,我已经能够成功地更改文档扩展并将其mime类型属性更新为MicrosoftWord2007(application/vnd.openxmlformats officedocument.wordprocessingml.document) 但是,当使用microsoft word下载并打开文件时,它会抛出一个错误,指出文件格式与扩展名不匹配 我以为我

我有一些文档最初作为.doc文件上传到alfresco share,其mimetype为Microsoft Word(应用程序/msword)

现在,我已经能够成功地更改文档扩展并将其mime类型属性更新为MicrosoftWord2007(application/vnd.openxmlformats officedocument.wordprocessingml.document)

但是,当使用microsoft word下载并打开文件时,它会抛出一个错误,指出文件格式与扩展名不匹配

我以为我做得对,但显然不对。 下面是应该处理mime类型转换的代码部分

Map<String, Object> updateProperties = new HashMap<String, Object>();

updateProperties.put("cmis:name", changeName);
updateProperties.put("cmis:contentStreamFileName", changeName);
document.updateProperties(updateProperties);

ContentStream contentStream = document.getContentStream();
InputStream stream = contentStream.getStream();
ContentStream cs1 = session.getObjectFactory().createContentStream(changeName, docLength, MimeTypes.getMIMEType("docx"), stream);

document.setContentStream(cs1, true);
Map updateProperties=newhashmap();
updateProperties.put(“cmis:name”,changeName);
updateProperties.put(“cmis:contentStreamFileName”,changeName);
文件。更新属性(更新属性);
ContentStream ContentStream=document.getContentStream();
InputStream=contentStream.getStream();
ContentStream cs1=session.getObjectFactory().createContentStream(changeName,docLength,MimeTypes.getMIMEType(“docx”),stream);
setContentStream(cs1,true);
在microsoft word中打开文档时,我收到的确切错误是:

“Word无法打开文件,因为文件格式与文件扩展名不匹配”


我不知道如何在更新期间更改文档的实际文件格式。看来这个解决方案不适合我。不确定我是否遗漏了什么。

出于兴趣,如果您使用Alfresco共享界面,编辑属性,并在那里更改文件名和Mime类型,Word是否会无误地打开文件?我也尝试过。同样的问题。如果您将文件下载到本地计算机,重命名扩展名,然后打开,可以吗?(我的直觉是它不会,因为我认为你有一个坏文件…)它也不会在我的本地机器上打开,因为该文件在alfresco中更改为.docx。将其更改回.doc会再次起作用。将其更改回.doc并再次下载会起作用,因此文件不会损坏。我认为在alfresco edit属性中更改mime类型只是元数据更改。我希望它能改变实际文档本身的文件格式,但事实并非如此。我可能需要使用ContentStream=document.getContentStream()的输出;在使用第三方java文档转换库执行更新之前,将流更改为.docx。