Permalink
Browse files

Edited facebook/src/com/facebook/android/Util.java via GitHub

1 parent 5d44d0c commit d0e6ca9d3ecfbe964e72803fdd340cfeafa6ee2e @johnmph committed Jul 2, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 facebook/src/com/facebook/android/Util.java
@@ -141,6 +141,16 @@ public static String openUrl(String url, String method, Bundle params)
OutputStream os;
+
+ // Try to get filename key
+ String filename = params.getString("filename");
+
+ // If found
+ if (filename != null) {
+ // Remove from params
+ params.remove("filename");
+ }
+
if (method.equals("GET")) {
url = url + "?" + encodeUrl(params);
}
@@ -185,7 +195,7 @@ public static String openUrl(String url, String method, Bundle params)
if (!dataparams.isEmpty()) {
for (String key: dataparams.keySet()){
- os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes());
+ os.write(("Content-Disposition: form-data; filename=\"" + ((filename) ? filename : key) + "\"" + endLine).getBytes());
@Ravi1988
Ravi1988 Mar 7, 2012

((filename) !=null ? filename : key) this would be a valid expression....

os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes());
os.write(dataparams.getByteArray(key));
os.write((endLine + "--" + strBoundary + endLine).getBytes());

4 comments on commit d0e6ca9

@johnmph
Owner
johnmph commented on d0e6ca9 Jul 2, 2011

Added filename parameter for uploading video with graph api

@Jeyaprakashchinaraj

Hi Johnmph,

      I implement this patch with my Facebook library , but still am getting {"error":{"message":"(#352) Video file format is not supported","type":"OAuthException"}} exception , i cannot upload any videos in my wall. can you give me suggestions for the same
@johnmph
Owner

Have you set the filename parameter (with the filename with extension) when you call openUrl ?

@Jeyaprakashchinaraj

Hi johnmph,

Yes, i have the latest apk download from github and i made 2 changes in my app , the first one is i add "param.putString("filename", "sample.mp4");" in Bundle.

The second one is i add below line in util.java class as you said

os.write(("Content-Disposition: form-data; filename=""
+ ((filename) != null ? filename : key) + """ + endLine).getBytes());

Please sign in to comment.