Dear Team,
I need to create a scripted custom field in which if i add an .docx file it should preview the content in the .docx file.
i have a script for .txt file but while m changing according to the .docx files its not working
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.FileSystemAttachmentDirectoryAccessor
def AttachmentDirecrotryAccessor= ComponentAccessor.getComponent(FileSystemAttachmentDirectoryAccessor)
def output=""
issue.attachments.each {
log.warn "Our File Name : ${it.filename}"
if(it.mimetype == "text/plain" || it.filename.endsWith(".txt"))
{
def directory = AttachmentDirecrotryAccessor.getAttachmentDirectory(issue)
def file = new File(directory, it.id.toString())
def firstLine = file.withReader { it.readLine()}
output += "$it.filename : <br>$firstLine<br><br>"
}
}
log.info "==========================="
log.info output
log.info "============================"
output
Hi Rajesh,
Docx files in groovy/java can be read only through Apache POI which is not included as a library in script runner.
Hence reading a docx file wont be possible.
Regards,
Anzar
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.