11-19-2012 07:38 AM
Hi,
I am having issue in sending the encrypted jpeg.rem image to the http server.
Till now i have no idea how to decrypt it(if it is possible) or if there is some way to read the encrypted jpeg.rem image and send to the server.
Please find the below code which i have use to send the unencrypted jpeg image to the http server-
private int readAndSendFile(String imagePath,String imageName,String Metadata, boolean isFileDelete) throws Exception
{
//#debug sample
System.out.println("Reading file 1");
OutputStream os = null;
InputStream is=null;
// DataOutputStream os = null;
// DataInputStream is=null;
HttpConnection c = null;
FileConnection f = null;
int rc=-1;
try
{
f=(FileConnection)Connector.open(imagePath.trim(), Connector.READ_WRITE);
is=f.openInputStream();
byte[] metaData = Metadata.getBytes();
int metaDataLength = metaData.length;
String url = ServiceURL+imageName+"~"+metaDataLength;
if (DeviceInfo.isSimulator()) {
url += ";deviceside=true";
}
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("Content-Length",String.value Of(f.fileSize()+metaDataLength));
c.setRequestProperty("Keep-Alive","timeout=3600000 0, max=36000000");
c.setRequestProperty("Connection","Keep-Alive");
c.setRequestProperty("Content-Type","application/o ctet-stream");
c.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");
//#debug sample
System.out.println("URL Request Property Set");
//Getting the output stream may flush the headers
os=c.openOutputStream();
int readBytes = 0;
//Reading the image in chunks and writing it
byte[] buf = new byte[1024];
while ((readBytes = is.read(buf)) != -1) {
os.write(buf,0,readBytes);
}
os.write(metaData);
os.flush();
// Getting the response code will open the connection,
// send the request, and read the HTTP response headers.
// The headers are stored until requested.
rc = c.getResponseCode();
}
catch(Exception e)
{
throw e;
}
finally
{
if(os!=null)
os.close();
if(is!=null)
is.close();
if(f!=null)
f.close();
if(c!=null)
c.close();
}
return rc;
}
Please suggest me if there is any solution to send the encrypted jpeg.rem image to the http server.
Any help in this regards will be a great favour.
Thanks.
11-26-2012 05:39 AM
Hi..
Did you find any solution to this??
I am stuck with the same issue.
Would really appreciate your help..pleaseeee
Thanks in advance.
11-26-2012 05:40 AM
hahaha.. dwimalu its youuuu