The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Questions

 
2
1
0

We got this situation.
We have a ADO to Jira integration

Jira allows the storage of only 10MB files.  The setting can be adapted by the Jira team wants to limit the size to 10 MB.


Question - How can we limit the attachments to only attachments lower than 10 MB.


    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi Francis Martens (iDalko) ,


      Excellent question. This can be done fairly easily. The attachment has a property called "filesize" which is expressed in bytes. So in the script, we can add some logic that will filter out all attachments that have the filesize value that is greater than 10.000.000 bytes. (1MB = 1.000.000 bytes). Here it is:

      def remoteAttachments = attachmentHelper.mergeAttachments(issue, replica)
      
      //The max size of the attachments in bytes. 1MB = 1.000.000 bytes
      def maxFileSize = 10000000
      def refacturedList = []
      for(file in remoteAttachments){
          if(file.filesize <= maxFileSize){
              refacturedList.add(file)
          }
      }
      issue.attachments = refacturedList


      In the script, you'll see that I created a new list, and in this list, I'll be adding all attachments that are larger than or equal to 10MB. 


      Best regards,

      Michiel



        CommentAdd your comment...