Code example for HttpPut

Methods: addHeadersetEntityaddHeadergetParams

0
 
		String fileName = sHelper.splitUriForFileName(imageUri);
		storageUri = Account.getStorageUrl() + "/" + containerName + "/" + fileName;
 
		HttpClient httpclient = new CustomHttpClient(context);
		HttpPut httpput = new HttpPut(storageUri);
		httpput.getParams().setIntParameter("http.socket.timeout", 100000);
 
		File file = new File(imageUri);
		ByteArrayEntity bae = null;
		try { 
			bae = new ByteArrayEntity(ByteHelper.getBytesFromFile(file));
		} catch (IOException e1) {
			e1.printStackTrace();
		} 
 
		httpput.setEntity(bae);
		httpput.addHeader("X-Auth-Token", Account.getAuthToken());
		httpput.addHeader("Content-Type", "application/octet-stream");
 
		try { 
			putResponse = httpclient.execute(httpput);
		} catch (ClientProtocolException e) {
			Log.e("Upload file", "Error in http connection " + e.toString());
		} catch (IOException e) {
			Log.e("Upload file", "Error in http connection " + e.toString());
		} 
Contextual code suggestions in your IDE  Get Codota for Java