Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
dwimalu
Posts: 4
Registered: ‎08-01-2012
My Carrier: HCL

How to decrypt encrypted jpeg.rem image and send to the http server

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.valueOf(f.fileSize()+metaDataLength));
			c.setRequestProperty("Keep-Alive","timeout=36000000, max=36000000");
			c.setRequestProperty("Connection","Keep-Alive");
			c.setRequestProperty("Content-Type","application/octet-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.

Please use plain text.
New Contributor
div15
Posts: 7
Registered: ‎01-27-2012
My Carrier: airtel

Re: How to decrypt encrypted jpeg.rem image and send to the http server

Hi..

 

Did you find any solution to this??

I am stuck with the same issue.

Would really appreciate your help..pleaseeee

 

Thanks in advance.

Please use plain text.
New Contributor
div15
Posts: 7
Registered: ‎01-27-2012
My Carrier: airtel

Re: How to decrypt encrypted jpeg.rem image and send to the http server

hahaha.. dwimalu its youuuu

Please use plain text.