Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void uploadDatabase() {
- AsyncHttpClient client = new AsyncHttpClient();
- // .setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
- try {
- if (databaseFile.isFile()) {
- byte[] myByteArray = FileUtils.readFileToByteArray(databaseFile); //Files.readAllBytes(videoFile.toPath());
- RequestParams params = new RequestParams();
- params.put("uploaded_file", new ByteArrayInputStream(myByteArray), "accelerometer.db");
- //params.put
- params.setForceMultipartEntityContentType(true);
- client.post(POST_URL, params, new AsyncHttpResponseHandler() {
- @Override
- public void onFinish() {
- Log.d("FINISH",this.getRequestHeaders().toString());
- Log.d("FINISH",this.getRequestURI().toString());
- // default log warning is not necessary, because this method is just optional notification
- }
- @Override
- public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
- if (statusCode == 200) {
- Log.d(TAG,"SUCCESS - The database uploaded successfully");
- }
- }
- @Override
- public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
- //Log.d("LOGGING HEADERS","FAILURE - Something went wrong. Plase try again later.");
- Log.d("NETWORK CONNECTION FAILED","FAILURE - Something went wrong. Please try again later.VINEEL" + error.getCause() +" ");
- }
- });
- } else {
- }
- } catch (Exception ex) {
- Log.e(TAG,"Exception while uploading video to server - "+ex.getMessage());
- ex.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement