Upload Excel File to Cloud Storage for Excel to PDF conversion in Java using Aspose.Cells REST API

Hi Aspose Technical Support,

I’m using Aspose.Cloud for converting from Excel to PDF. Today (12-June-2014), we almost have errors in uploading Excel files to Aspose (from 08:34 GMT+07 to 10:40 GMT+07. After 10:40, everything is normal. Did you make any changes on Aspose.Cloud Server on that time ?

This is my code for upload files to Aspose in Java :

/**
* Upload file into server aspose.cloud
*
* @param data
* @param uploadUrl
* @return
*/
private static String uploadFile(byte[] data, String uploadUrl,
Map<String, Object> outputData) {

// String uploadUrl =
// “http://api.aspose.cloud/v1.0/cell/chien-taomoi.xlsx”;
System.out.println("upload URL : " + uploadUrl);
try {
URL url = new URL(uploadUrl);
HttpURLConnection m_connection;
m_connection = (HttpURLConnection) url.openConnection();
// m_connection.setAllowUserInteraction(true);
// Increase the Connection Timeout
m_connection.setConnectTimeout(3 * 60 * 1000);

m_connection.setDoOutput(true);
m_connection.setRequestMethod(“PUT”);
m_connection.setRequestProperty(“Accept”, “text/json”);
m_connection.setRequestProperty(“Content-Type”,
“MultiPart/Form-Data”);
m_connection.setRequestProperty(“Content-length”, “” + data.length);
m_connection.connect();
java.io.OutputStream out = new BufferedOutputStream(
m_connection.getOutputStream());
out.write(data);
out.flush();

InputStream response = m_connection.getInputStream();
String res = com.saaspose.common.Utils.StreamToString(response);
response.close();
out.close();
m_connection.disconnect();

if (null != outputData) {
outputData.put(“resultUpload”, res);
}

// Parse result of uploading file for checking errors
JSONObject objResult = new JSONObject(res);
// {“Code”:200,“Status”:“OK”}
String code = objResult.getString(“Code”);
String status = objResult.getString(“Status”);
if (false == “200”.equalsIgnoreCase(code)) {
throw new Exception(“Code of upload != 200”);
}
if (false == “OK”.equalsIgnoreCase(status)) {
throw new Exception(“Status of upload != OK”);
}

return res;
} catch (Exception e) {
String exInfo = Utils.exceptionToString(e);
// e.printStackTrace();
log.severe("Exception in upload file : " + exInfo);

if (null != outputData) {
outputData.put(“exception”, exInfo);
}
return null;
}
}

And this is the error information :
Exception info : java.io.IOException: Could not fetch URL:

http://api.aspose.com/v1.1/storage/file/Yorba-Linda-Circle-K-Mobil-2709434-04-26-2014-CK-FFC-Fuel-Equip-Maint-C4104246-P1_1302559.xlsx?appSID=febd886e-b9dc-4514-9deb-73f48f81dc71&signature=0lsIBanrhFT05lCjiGrGQxGrVj8com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:139)
com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:45)

com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:417)

com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:296)

com.mdt.doforms.portal.utils.AsposeCellsUtils.uploadFile(AsposeCellsUtils.java:125)

com.mdt.doforms.portal.utils.AsposeCellsUtils.getPdfDownloadDataNewMethod(AsposeCellsUtils.java:346)

com.mdt.doforms.portal.utils.AsposeCellsUtils.getPdfDownloadData(AsposeCellsUtils.java:176)</i>

Thanks,
Chien

Hi Chien,

We did not make any changes but we will investigate why this issue arose at your end and let you know.

Best Regards,

Hi Chien,

Sorry we did not find and issue with your account or during those hours. Did you notice a similar issue after that?

Best Regards,

@tdchien

As an update, please note latest API Version V3 of Aspose.Cells Cloud has very simplified and improved code. It is better than previous versions in terms of API structure and memory management. Please find sample Aspose.Cells Cloud SDK for Java code to upload file to cloud storage. You can check latest SDK from Github Repo and feel free to ask any question or concern.

File file = new File("C:/Temp/test.xlsx");
    try {
    	 CellsApi api = new CellsApi(aapSID,aapKey);
         System.out.print("done");
    } catch (ApiException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }