, -, . , , , (multipart) "" .
Android Android SDK, Bundle :
public void writeObject(String key, Object value) throws IOException {
if (isSupportedParameterType(value)) {
writeString(key, parameterToString(value));
} else if (value instanceof Bitmap) {
writeBitmap(key, (Bitmap) value);
} else if (value instanceof byte[]) {
writeBytes(key, (byte[]) value);
} else if (value instanceof ParcelFileDescriptor) {
writeFile(key, (ParcelFileDescriptor) value, null);
} else if (value instanceof ParcelFileDescriptorWithMimeType) {
writeFile(key, (ParcelFileDescriptorWithMimeType) value);
} else {
throw new IllegalArgumentException("value is not a supported type: String, Bitmap, byte[]");
}
}
public void writeBitmap(String key, Bitmap bitmap) throws IOException {
writeContentDisposition(key, key, "image/png");
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
writeLine("");
writeRecordBoundary();
logger.appendKeyValue(" " + key, "<Image>");
}
, Bundle . Bundle . getImageFormData :
public Bitmap getImageFormData(File image) {
return BitmapFactory.decodeFile(image.getPath());
}
ParcelFileDescriptor, :
public ParcelFileDescriptor getImageFormData(File image) {
try {
return ParcelFileDescriptor.open(image, ParcelFileDescriptor.MODE_READ_ONLY);
} catch (FileNotFoundException e) {
return null;
}
}
( url ):
public static Request newUploadStagingResourceWithImageRequest(Session session,
Bitmap image, Callback callback) {
Bundle parameters = new Bundle(1);
parameters.putParcelable(STAGING_PARAM, image);
return new Request(session, MY_STAGING_RESOURCES, parameters, HttpMethod.POST, callback);
}