Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

duplicated attachments in a space: writing code for scriptrunner for blocking or notification of

Steve Hastings
Contributor
January 9, 2019

Hi all,

 I am trying to block or notify the occurrence of attachments with the same filename in a space. I have been in touch with the clever team at Adaptavist. Their Scriptrunner product has the capacity, using the Listener feature to raise these notifications. Our conversations with Tony at Adaptavist are below. 

Is there anyone there who would be interested in creating the Listener script for Confluence Cloud (and Server) proposed by Tony? I'm happy to pay for your efforts or it would be script we could share with the community.

Please let me know! Thanks very much. Steve

 

  • Tony Gough

    7 hours ago

    Hi Steve,

    Unfortunately we are limited in our capacity to help customers with custom coding questions, as these by their very nature are limitless. Atlassian has a community site, which is our preferred venue for custom code Q&A. This also enables us to put information like this in a more public space, so that everyone benefits from the answer. We of course prioritize support covered by our SLA, but we do try to answer community questions when we can.

    That said, you should find the Confluence Cloud REST API helpful. You should be able to accomplish what you need making appropriate rest calls to Get content and Get attachments.

    I hope you find this information useful.

    Kind regards,
    Tony

     

  • Your request status changed to Waiting for Customer.7 hours ago
  • Steve Hastings

    Steve Hastings

    Yesterday 9:14 PM

    Hi Tony. Thank you very much for your help on this. I will further investigate an event listener. If I need help creating the script can you recommend a team who could do that?
    Thanks, Steve

  • Your request status changed to With Support.Yesterday 9:14 PM
  • Your request status changed to Waiting for Customer.Yesterday 11:01 AM
  • Tony Gough

    Tony Gough

    Yesterday 11:01 AM

    Hi Steve,

    It sounds like what you want should be achievable using an event listener which fires on the Attachment Created event. This will give you access to the 'attachments' variable which contains a list of attachments which were uploaded, as well as the 'attachedTo' variable which represents the page.

    Further information is available on the Confluence Cloud API documentation, which is linked to from the ScriptRunner Script Listeners page.

    I hope this is helpful to you, please let us know if you have anything further.

    Kind regards,
    Tony

     

     

  • Your request status changed to With Support.Yesterday 10:50 AM
  • Adaptavist Support

    Adaptavist Support

    Yesterday 3:15 AM

    Thanks for raising a request with Adaptavist Support. Please note our team is based in the UK and operate UK working hours, 9am to 5pm Monday to Friday. We try to respond to all new requests within 24 hours.

    If your request is about getting help with one of your scripts, please consider using the following resources:

    Thanks,
    The Adaptavist Support team

  • Details

    Yesterday 3:15 AM
    SEN
    279abfba-b315-3e72-90b9-3cea529a48d6
    ScriptRunner Licence
    Evaluation
    Licence Tier
    Server - 10 users - starter licence
    Atlassian Version
    Confluence
    Data Center?
    No
    Description

    hi there, I am trying to block the occurrence of attachments with the same filename in a space. how can I use scriptrunner for confluence cloud to raise an alert when scriptrunner detects two attachments of the same filename within a confluence space?
    thanks and kind rgds, Steve

 

 

https://productsupport.adaptavist.com/servicedesk/customer/portal/40/SRCLSUP-9

1 answer

1 accepted

0 votes
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2019

I wrote a script like this for Jira that will compare attachments on ticket A to the attachment being uploaded on ticket B. If it matches any on ticket A the attachment will be deleted. Some of my code could probably be recycled into what you are trying to do. Alas, I do not have ScriptRunner for Confluence. Below are the Community articles I wrote about it.

Remove Jira Issue Attachments by MD5 Hash
Remove Jira Issue Attachments by MD5 Hash Redux

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2019

As  think about it from a design standpoint you would probably want to persistently store the hashes of all your attachments in the database so that you can compare quickly against the has of the attachment being uploaded. It would probably be a drain on the system to do a realtime scan to get the hashes of all the current attachments when the upload listener fires off.

Steve Hastings
Contributor
January 10, 2019

Thank you Davin for your great input.Much appreciated! I'll let all know how I go. Kind Rgds, Steve

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events