今日のひとこと Challange IT For Future

nt:fileとnt:resource

JCR 読了 2分

この記事は最終更新から 20 年以上たっています。内容が現在の状況と異なる可能性があります。現在の情報は最新の記事、Fess の記事をご覧ください。

CMSとかで、ファイルを保存するときには、nt:fileとnt:resourceを使うみたい。っで、作ったやつはどう呼び出すのだろうか・・・。

//create the file node - see section 6.7.22.6 of the spec
Node fileNode = folderNode.addNode (file.getName (), "nt:file");
//create the mandatory child node - jcr:content
Node resNode = fileNode.addNode ("jcr:content", "nt:resource");
resNode.setProperty ("jcr:mimeType", mimeType);
resNode.setProperty ("jcr:encoding", encoding);
resNode.setProperty ("jcr:data", new FileInputStream (file));
Calendar lastModified = Calendar.getInstance ();
lastModified.setTimeInMillis (file.lastModified ());
resNode.setProperty ("jcr:lastModified", lastModified);