After filling necessary package info, I manage to create a responsed Transaction object through goShippo API call: Transaction.create(Map, apiKey). Form the responsed Transaction object, I can get the shipping label as a Url: transaction.getObjectId().
The problem that I have is how can I enable my client to download the shipping label.
My current code is:
fileName= "https://shippo-delivery-east.s3.amazonaws.com/b1b0e6af.pdf?xxxxxx";
File file = new File(fileName);
String mineType = URLConnection.guessContentTypeFromName(file.getName());
if(mineType == null) {
System.out.println("mineType is not detectable");
mineType = "application/octet-stream";
}
response.setContentType(mineType);
response.setHeader("Content-Disposition"
, String.format("inline; filename=\"" + file.getName() +"\""));
response.setContentLength((int)file.length());
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
FileCopyUtils.copy(inputStream, response.getOutputStream());
The error that I have is that the file is not found, but when I pass the fileName on browser, I can see the shipping label.