Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting attachments files during transition

Hi all!

I'm trying to get attaches were attached during transition as a files.

I can get them using 

def attaches = issue.modifiedFields.get(IssueFieldConstants.ATTACHMENT)?.newValue

and i get list of temporary filenames. And i can get them like files using

attaches .each{attach ->
log.warn 'New Attach'
log.warn attach
newAttList.add(new LazyMap ('fileName': attach, 'file':new File(temporaryAttachmentDirectory, attach)))
}

But there are not properly filenames  - only temporary like temp2135062013794563645. So i can't do anything correct with this files.

Otherwise, i can get list of TemporaryWebAttachment objects using 

def temporaryAttachmentUtil = ComponentAccessor.getComponent(TemporaryWebAttachmentManager)
def formToken = ActionContext.getRequest()?.getParameter(IssueFieldConstants.FORM_TOKEN)

def newAttaches = temporaryAttachmentUtil.getTemporaryWebAttachmentsByFormToken(formToken)

But i couldn't find out how can i get File object from TemporaryWebAttachment. It has filename property, but it's only name of file wich was attached, but i can't find it nowere in filesystem. Also i can't attachment from issue via attachment name - only by attachment id. But i can't get attachment id information from TemporaryWebAttachment.

Anybody knows how to get file object from transition attachment? I'll be greatly thankfull. 

1 answer

1 accepted

0 votes
Answer accepted

Just found it by myself.

TemporaryWebAttachment.getStringId() returns exactly temporary attachment name

so i could get File like this:

new File(temporaryAttachmentDirectory,TemporaryWebAttachment.getStringId())

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you