Wednesday, June 25, 2014

How to add binary property for Node in CQ

Motivation: Recently I was trying to add some binary property to a node through file system (As part of code deployment). Had hard time figuring out how we can do that.

Use Case: You need to add some Binary property to a node through file system. (One use case is adding SAML cert as property idp_cert under /etc/key/saml)

Solution:

Option 1:

You can use following curl command to do that (Look at \< )


curl -u UID:PWD -F property_name=\<File location -F property_name@TypeHint=Binary http://HOST:PORT/PATH_WHERE_YOU_WANT_TO_ADD_THIS_PROP

If you are trying to upload a file instead of property, You can use something like, (This is even true for if you want to install a bundle using repo path in that case repo path would be something like /apps/your_app/install if this is Adobe bundle then something like /libs/adobe_modules/install and if this is system bundle (Like Authentication bundles) then it would be something like /libs/system/install

curl -u UID:PWD -T File_Location HOST:PORT/PATH

Option 2: 

You can use .content.xml to create property like this

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
    your_property-name="{Binary}"
    jcr:primaryType="sling:Folder"/>

And then create a file called  your_property-name.binary at same level and dump your binary content there. When you use maven-content-plugin to build package now, vlt knows how to transform this to a binary property.

----- /somepath
-------- .content.xml
-------- your_property_name.binary

Note that there are various way to create actual binary content in CQ using curl and some of them you can check here 

41 comments:

  1. Hi ,
    How can i add a cq node with specific type, for an example Long type.

    curl -u admin:admin -X POST --data size=70 http://localhost:4502/content/

    if i use the above command it will create a node but with sting type. i want to make it Long.

    ReplyDelete
    Replies
    1. If you are trying to add property to Node with a type then you can use @TypeHint more example here http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google. House for Sale

    ReplyDelete
  4. Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this. Its really good. Ann Arbor Apartments

    ReplyDelete
  5. One of the more impressive blogs Ive seen. Thanks so much for keeping the internet classy for a change. Youve got style, class, bravado. I mean it. Please keep it up because without the internet is definitely lacking in intelligence. Boulevard 88 floor plan

    ReplyDelete
  6. It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. house for Sale

    ReplyDelete
  7. I real glad to uncover this web internet site on bing, just what I was searching for. Buy new gutters

    ReplyDelete
  8. Regular visits listed here are the easiest method to appreciate your energy, which is why why I am going to the website everyday, searching for new, interesting info. Many, thank you  Click here

    ReplyDelete
  9. I truly welcome this superb post that you have accommodated us. I guarantee this would be valuable for the vast majority of the general population. Pick the Right Contractor

    ReplyDelete
  10. I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Gutters Raleigh NC

    ReplyDelete
  11. This article is an appealing wealth of informative data that is interesting and well-written. I commend your hard work on this and thank you for this information. You’ve got what it takes to get attention. Residential Gutter systems

    ReplyDelete
  12. Hmm!! This blog is really cool, I’m so lucky that I have reached here and got this awesome information. Seamless gutter company

    ReplyDelete
  13. New web site is looking good. Thanks for the great effort. recover money lost to binary options

    ReplyDelete
  14. Specialists for the new property owner(s) will ordinarily check this and offer techniques for arrangement at the season of offer.register extract

    ReplyDelete
  15. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. ChoreRelief

    ReplyDelete
  16. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks Enbloc Sale for Property

    ReplyDelete
  17. Regular servicing and maintenance will help prolong the life of the equipment and maximise the overall performance through its lifecycle. commercial plumber

    ReplyDelete
  18. The Management Team at Property Services Inc is dedicated to providing excellent customer service and property management services to tenants and clients respectively. It is our goal to maximize property values to the highest potential and reduce operating expenses without affecting the quality of property performance. Company Name = Auction Properties UK Phone = 08000246216 Address = 183 Meanwood Road, Leeds, West Yorkshire, LS7 1NB. auction house in leeds

    ReplyDelete
  19. A tenancy schedule should be sourced for the property and checked totally. What you are looking for here is an accurate summary of the current lease occupancy and rentals paid. zillow ocala fl 34471

    ReplyDelete
  20. i read a considerable measure of stuff and i found that the method for composing to clearifing that precisely need to say was great so i am inspired and ilike to come back again in future.. Commercial Contractor Maryland

    ReplyDelete
  21. I think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing. Maid Service

    ReplyDelete
  22. Goodness, cool post. I'd like to compose like this as well – requiring significant investment and genuine diligent work to make an incredible article… yet I put things off an excessive amount of and never appear to begin. Much appreciated however. CBD (cannabidiol) oil for sale

    ReplyDelete
  23. Wow! This could be one particular of the most helpful blogs We’ve ever arrive across on this subject. Basically Magnificent. I am also an expert in this topic so I can understand your effort 123Movies

    ReplyDelete
  24. Hi it’s me, I am also visiting this website regularly, this web page is in fact nice and the viewers are truly sharing fastidious thoughts. Fmovies

    ReplyDelete
  25. I have found out and have more information on this issue if you are interested please contact us Yesmovies

    ReplyDelete
  26. I was rattling glad to find this web site on bing, just what I was looking for Solarmovie

    ReplyDelete
  27. Really suprised with these things, i have thought it would be different. Thanks for useful information Jav Uncensored

    ReplyDelete
  28. Thank you and thank for your shared, i will introduce to my friend to visit your website more often Jav Hot

    ReplyDelete
  29. Hello, i just want to thank you for your excellent article. Keep it well Jav Censored

    ReplyDelete
  30. Its very useful, without read your article, it hard to think about. Thank you so much.Jav Censored

    ReplyDelete
  31. Well! I have thrown my phone away, turned on computer, logged in and commented your article.LOL. This is so hilarious.

    Japanese Porn

    ReplyDelete
  32. I were caught in same trouble too, your solution really good and fast than mine. Thank you.
    /
    Jav Censored

    ReplyDelete
  33. Though i have learned about it but after read your articles, i just realized the amount of knowledge that i missed. Thank for your shared 123Movies

    ReplyDelete
  34. It is nearly not possible to find knowledgeable folks about this topic, but the truth is sound like do you realize what you are coping with! Thanks 123Movies
    Movies123
    FMovies
    YesMovies

    ReplyDelete
  35. Merely wanna remark that you have a very nice internet site , I enjoy the style and design it actually stands out. Bệnh Lậu

    ReplyDelete
  36. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. NPPM

    ReplyDelete
  37. I high appreciate this post. It’s hard to find the good from the bad sometimes, but I think you’ve nailed it! would you mind updating your blog with more information? https://sieukeo.com/ty-le-keo

    ReplyDelete
  38. 123movies industry and create problems for all softwa

    ReplyDelete
  39. I was suggested this website by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem. You’re incredible! Thanks!gogoanime

    ReplyDelete