Atlassian
We are programmatically uploading attachments of size 13MB/19MB, using SOAP to Jira CRs, but it takes indefinite time to upload and fails saying socket timeout error
We compared the time taken to upload on 2 jira instances:
# One jira instance with v5.0.4
# and another jira instance with 3.13.2
below is the table with timings:
||Jira instance||File size||Trial 1||Trial 2||Trial 3||Average time to upload||Programmatically/UI||Jira version||
|Jira Old|993 KB|10.14 s|17.65 s|9.57 s|12.45 s|UI|3.13.2|
|Jira New|993 KB|2.9 s|4.21 s|20.8 s|9.31 s|UI|v5.0.4|
|Jira Old|37 KB|12.4 m|13.6 m|12.3 m|12.76 m|Programmatically|3.13.2|
|Jira New|36 KB|2.43 m|1.95 m|2.48 m|2.29 m|Programmatically|v5.0.4|
below is the SOAP code used to upload the file.
{code}
...
...
File tmpFile = new File(Log_B2G.zip);
String fileName = tmpFile.getName();
added = jiraSoapObject.addAttachmentsToIssue(token, issueKey, new String { fileName },
new byte { getBytesFromFile(tmpFile) });
...
...
...
private static byte getBytesFromFile(File file) throws IOException {
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length < Integer.MAX_VALUE) {
// Create the byte array to hold the data
byte bytes = new byte (int) length ;
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
System.out.println(numRead:+numRead+ t offset:+offset);
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException(Could not completely read file + file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;
} else {
System.out.println(File is too large);
return null;
}
}
{code}
Please confirm with us if this is the best code implementation to upload attachment files for version 5.0.4
And why does it take to upload so long and fails for attachments that are 900KB, because this is a blocker for us to be unable to upload files programmatically.
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.