I have created a repo and I posted some images and documents successfully. I have read those images and documents but I’m not sure how to display them in the view. Is there any library that can help me processing the binary data?
I’d like to be more specific with my question. I’ve seen in some examples that when the file or image is in the content repository you can use imageUrl or attachmentUrl to point to that file/image. How could I do that when the file/image is in a different repo?
imageURL or attachmentUrl methods are specific to the CMS solution in enonic. So what you need to do is to create a service that you can use to get the node and stream the attachment inside that node.
Hmm… can’t help with the lib, but is’nt it really the example in the code you are interested in? You should not be reading/writing files in your use-case, but use repo if I have understood it correctly.
We also serve assets from the repo in the office league app, could be worth having a look at that code too?
I’m new with Enonic so I’m trying different ways to do the same thing to see which way is better. Basically I have created a repo to store documents. I wanted to try that library and the way you do it in Office League as well. I’ve tried to install the filesystem library unsuccessfully (so I think I will leave this library for now). Following the approach in Office League I have stored files in the repo that I have created and I read them. I can read the documents but they are just binary data. I’ve seen that in office league u use a Java based Image Handler to process the images. For the project that I have to develop I need to work with documents only so I will leave the image testing for now, the question now is how can I process that binary data to display/download the documents (pdfs)?
My code works with plain text files. I can save those files in the repo that I created and I can read them. The problem is when I want to store/read pdf files so I think it’s an encoding problem. This is what I do:
When I upload the pdf files I use getMultipartStream in the portal library. Then I get a data-stream.
Then I use the function binary in Value library to get a binaryAttachment java-type that I can store in my repo.
To read the files I use getBinary in RepoConnection Library but the documentation doesn’t say anything about the return type.
Is this correct? Is there any enconding/decoding process in the middle? How can I display/download the read files in the client side?