JIRA cloud scriptrunner - Bad filename after post attachment

Viewed 9

I have a problem with a filename when I try to post attachment into an issue. If the attachment's filename contains non ASCII characters, the characters are changed into the question marks, eg. "?esk?_Republika.png" vs. "Česká_Republika.png". The attachment is always saved into an issue and I can properly open it, the file is OK.

The code is:

def fileName = 'Česká_Republika.png'

def attachmentContent = get('/rest/api/3/attachment/content/10078')
    .header('Accept', 'application/json')
    .asBinary()
    .body
    
InputStream stream = new ByteArrayInputStream(attachmentContent.getBytes())

def attachmentPost = post('/rest/api/3/issue/TIP-63/attachments')
    .header('Accept', 'application/json')
    .header('X-Atlassian-Token', 'no-check')
    .field('file', stream, fileName)
    .asJson()

I hope for your kind help and look forward for your answers.

Thank you in advance so much.

Lukas

0 Answers
Related