Exact search for an attachment using the attachment name in Java

Hi, 

I want to check (in Java) if an attachment with a given filename already exists in my entire Confluence system. I was able to perform a V2 search and limit the results by ContentType, but how can query for a specific attachment name? What type of Query Object do I have to use and how would the constructor look like?

 

Thanks

Thorstne 

1 answer

0 vote
Ann Worley Atlassian Team Jul 10, 2017

If you just need to know if the attachment exists in the instance you can query the database with a query like this, which worked on my PostgreSQL db:

select * from content where contenttype = 'ATTACHMENT' and title = '<filename_case_sensitive>';

If you need to do it in Java because of a solution you are building then we will have to defer to the more Java savvy members of the Community.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

974 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you