in facebook-android-wrapper/src/com/facebook/unity/FB.java [596:640]
public static void UploadImageToMediaLibrary(String params_str) {
Log.v(TAG, "UploadImageToMediaLibrary(" + params_str + ")");
UnityParams unityParams = UnityParams.parse(params_str);
String caption = unityParams.getString("caption");
Uri imageUri = Uri.parse(unityParams.getString("imageUri"));
// As a convenience, convert the URI to file:// if it has no Scheme.
// this is so that Unity code can pass just the path to the local
// file.
if (imageUri.getScheme() == null) {
imageUri = imageUri.buildUpon().scheme("file").build();
}
boolean shouldLaunchMediaDialog = Boolean.parseBoolean(unityParams.getString("shouldLaunchMediaDialog"));
final UnityMessage unityMessage = new UnityMessage("OnUploadImageToMediaLibraryComplete");
if (unityParams.hasString("callback_id")) {
unityMessage.put("callback_id", unityParams.getString("callback_id"));
}
GamingImageUploader imageUploader = new GamingImageUploader(getUnityActivity());
try {
imageUploader.uploadToMediaLibrary(
caption,
imageUri,
shouldLaunchMediaDialog,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
unityMessage.sendError(response.getError().toString());
} else {
String id = response.getJSONObject().optString("id", null);
if (id == null) {
unityMessage.sendError("Response did not contain ImageID");
} else {
unityMessage.put("id", id);
unityMessage.send();
}
}
}
}
);
} catch (FileNotFoundException e) {
unityMessage.sendError(e.toString());
}
}