public void writeBytes(String key, byte[] bytes) throws IOException { writeContentDisposition(key, key, "content/unknown"); this.outputStream.write(bytes); writeLine(""); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue( " " + key, String.format(Locale.ROOT, "<Data: %d>", bytes.length)); } }
public void writeBitmap(String key, Bitmap bitmap) throws IOException { writeContentDisposition(key, key, "image/png"); // Note: quality parameter is ignored for PNG bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); writeLine(""); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue(" " + key, "<Image>"); } }
public void writeString(String key, String value) throws IOException { writeContentDisposition(key, null, null); writeLine("%s", value); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue(" " + key, value); } }
public void writeRequestsAsJson( String key, JSONArray requestJsonArray, Collection<GraphRequest> requests ) throws IOException, JSONException { if (!(outputStream instanceof RequestOutputStream)) { writeString(key, requestJsonArray.toString()); return; } RequestOutputStream requestOutputStream = (RequestOutputStream) outputStream; writeContentDisposition(key, null, null); write("["); int i = 0; for (GraphRequest request : requests) { JSONObject requestJson = requestJsonArray.getJSONObject(i); requestOutputStream.setCurrentRequest(request); if (i > 0) { write(",%s", requestJson.toString()); } else { write("%s", requestJson.toString()); } i++; } write("]"); if (logger != null) { logger.appendKeyValue(" " + key, requestJsonArray.toString()); } }
public void writeContentUri(String key, Uri contentUri, String mimeType) throws IOException { if (mimeType == null) { mimeType = "content/unknown"; } writeContentDisposition(key, key, mimeType); int totalBytes = 0; if (outputStream instanceof ProgressNoopOutputStream) { // If we are only counting bytes then skip reading the file long contentSize = Utility.getContentSize(contentUri); ((ProgressNoopOutputStream) outputStream).addProgress(contentSize); } else { InputStream inputStream = FacebookSdk .getApplicationContext() .getContentResolver() .openInputStream(contentUri); totalBytes += Utility.copyAndCloseInputStream(inputStream, outputStream); } writeLine(""); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue( " " + key, String.format(Locale.ROOT, "<Data: %d>", totalBytes)); } }
logger.appendKeyValue("Id", requests.getId()); logger.appendKeyValue("URL", url); logger.appendKeyValue("Method", connection.getRequestMethod()); logger.appendKeyValue("User-Agent", connection.getRequestProperty("User-Agent")); logger.appendKeyValue("Content-Type", connection.getRequestProperty("Content-Type"));
public void writeFile( String key, ParcelFileDescriptor descriptor, String mimeType ) throws IOException { if (mimeType == null) { mimeType = "content/unknown"; } writeContentDisposition(key, key, mimeType); int totalBytes = 0; if (outputStream instanceof ProgressNoopOutputStream) { // If we are only counting bytes then skip reading the file ((ProgressNoopOutputStream) outputStream).addProgress(descriptor.getStatSize()); } else { ParcelFileDescriptor.AutoCloseInputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(descriptor); totalBytes += Utility.copyAndCloseInputStream(inputStream, outputStream); } writeLine(""); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue( " " + key, String.format(Locale.ROOT, "<Data: %d>", totalBytes)); } }
public void writeBytes(String key, byte[] bytes) throws IOException { writeContentDisposition(key, key, "content/unknown"); this.outputStream.write(bytes); writeLine(""); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue(" " + key, String.format("<Data: %d>", bytes.length)); } }
public void writeBitmap(String key, Bitmap bitmap) throws IOException { writeContentDisposition(key, key, "image/png"); // Note: quality parameter is ignored for PNG bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); writeLine(""); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue(" " + key, "<Image>"); } }
public void writeString(String key, String value) throws IOException { writeContentDisposition(key, null, null); writeLine("%s", value); writeRecordBoundary(); if (logger != null) { logger.appendKeyValue(" " + key, value); } }
public void writeRequestsAsJson(String key, JSONArray requestJsonArray, Collection<Request> requests) throws IOException, JSONException { if (! (outputStream instanceof RequestOutputStream)) { writeString(key, requestJsonArray.toString()); return; } RequestOutputStream requestOutputStream = (RequestOutputStream) outputStream; writeContentDisposition(key, null, null); write("["); int i = 0; for (Request request : requests) { JSONObject requestJson = requestJsonArray.getJSONObject(i); requestOutputStream.setCurrentRequest(request); if (i > 0) { write(",%s", requestJson.toString()); } else { write("%s", requestJson.toString()); } i++; } write("]"); if (logger != null) { logger.appendKeyValue(" " + key, requestJsonArray.toString()); } }
writeRecordBoundary(); if (logger != null) { logger.appendKeyValue(" " + key, String.format("<Data: %d>", totalBytes));
logger.appendKeyValue("Id", requests.getId()); logger.appendKeyValue("URL", url); logger.appendKeyValue("Method", connection.getRequestMethod()); logger.appendKeyValue("User-Agent", connection.getRequestProperty("User-Agent")); logger.appendKeyValue("Content-Type", connection.getRequestProperty("Content-Type"));