Storing Attachments in S3

https://confluence.atlassian.com/adminjiraserver101/storing-attachments-in-amazon-s3-1455429114.html

I have gone through the following doc already.
https://confluence.atlassian.com/adminjiraserver101/storing-attachments-in-amazon-s3-1455429114.html

In below snapshot we can see the path is also change to the bucket name that we want

Now the priblem is attachments are still getting saved in /Appdata/data/attachments path only, but we need that to be in S3 bucket now. How can we do it using

com.thed.zephyr.je.service.AttachmentManager;

I know AttachmentManager is resoponsible for saving it, but i am not getting how to save it in S3. Can anyone please help.

Below is the code that we are using…

public static String getAttachmentDirName()
    {
        Object component = ZephyrComponentAccessor.getInstance().getComponent("clusterProperties");
        if (!(component instanceof ClusterProperties)) {
            throw new IllegalStateException("ClusterProperties bean is not of the expected type");
        }
        ClusterProperties clusterProperties = (ClusterProperties) component;
//    	ClusterProperties clusterProperties = (ClusterProperties) ZephyrComponentAccessor.getInstance().getComponent("clusterProperties");
    	String shareHome = null;
    	if(StringUtils.isNotBlank(clusterProperties.getSharedHome()))
    		shareHome = clusterProperties.getSharedHome();
    	else
    		shareHome = clusterProperties.getHomeDirectory();
    	
    	String attachmentsDirectory = Paths.get(shareHome, "data", "attachments").toAbsolutePath().toString();
    	return attachmentsDirectory;
//    	return 
//        return ComponentAccessor.getAttachmentPathManager().getAttachmentPath();
    }

We are running jira dc it on local, from there we want to upload all attachments to S3. any documentation reference will be of great help.

2 Likes

Hi @RaghunandanTata,

you need to use com.atlassian.jira.issue.AttachmentManager.createAttachment to create the attachment.
To retrieve the contents of an attachment you can use AttachmentManager.streamAttachmentContent.
The AttachmentManager will take care of everything else, i.e. storing and getting the attachment from the S3 Bucket or from the local attachment directory, if the Jira instance does not use S3.