Storing and consuming content from Parse
Parse is a very powerful tool that allows us to not only consume content very easily but also to store content in the cloud database from our device, which is a tedious task to do using the traditional method.
For example, if we wanted to upload an image to a custom server from our device, we would have to create a POST
request and send a form with the right encoding, while attaching the picture as a FileBody
object in MultiPartEntity
and importing the Apache HTTP libraries:
HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("URL TO SERVER"); MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); File file = new File(filePath); mpEntity.addPart("imgField", new FileBody(file, "application/octet")); httppost.setEntity(mpEntity); HttpResponse response = httpclient.execute(httppost);
Now, let's have a look at the Parse alternative:
ParseFile imgFile = new ParseFile...