|
String APP_KEY = ""; // Get AppKey and AppSID from https:dashboard.aspose.cloud/ |
|
String APP_SID = ""; // Get AppKey and AppSID from https:dashboard.aspose.cloud/ |
|
String DATA_PATH = "src/main/resources/"; |
|
|
|
ImagingApi imagingApi = new ImagingApi(APP_KEY, APP_SID); |
|
|
|
String fileName = "Sample.tiff"; // Original image file name |
|
String appendFileName = "Memorandum.tif"; // Image file name to be appended to original one |
|
|
|
try { |
|
// Upload original image file to cloud storage |
|
File inputFile = new File(Main.DATA_PATH + fileName); |
|
FileInputStream localInputImageStream = new FileInputStream(inputFile); |
|
|
|
byte[] localInputImage = IOUtils.toByteArray(localInputImageStream); |
|
|
|
UploadFileRequest uploadFileRequest = new UploadFileRequest(fileName, localInputImage, null); |
|
FilesUploadResult inputFileResult = imagingApi.uploadFile(uploadFileRequest); |
|
|
|
// Upload file be appended to cloud storage |
|
File appendFile = new File(Main.DATA_PATH + appendFileName); |
|
FileInputStream appendFileImageStream = new FileInputStream(appendFile); |
|
|
|
byte[] appendFileImage = IOUtils.toByteArray(appendFileImageStream); |
|
|
|
UploadFileRequest uploadAppendFileRequest = new UploadFileRequest(appendFileName, appendFileImage, null); |
|
FilesUploadResult appendFileResult = imagingApi.uploadFile(uploadAppendFileRequest); |
|
|
|
// Update TIFF Image parameters according to fax parameters |
|
String folder = null; // Input file is saved at the root of the storage |
|
String storage = null; // We are using default Cloud Storage |
|
|
|
PostTiffAppendRequest request = new PostTiffAppendRequest(fileName, appendFileName, storage, folder); |
|
imagingApi.postTiffAppend(request); |
|
|
|
// Download updated file to local storage |
|
DownloadFileRequest downloadFileRequest = new DownloadFileRequest(fileName, storage, null); |
|
byte[] updatedImage = imagingApi.downloadFile(downloadFileRequest); |
|
|
|
// Save updated image to local storage |
|
FileOutputStream fos = new FileOutputStream(Main.DATA_PATH + "Sample_out.tiff"); |
|
fos.write(updatedImage); |
|
fos.close(); |
|
|
|
} catch (Exception e) { |
|
System.out.println(e.getMessage()); |
|
} |