Antzi
Antzi

Reputation: 13444

Facebook SDK for Android: Fail to upload a video

I'm trying to upload a video using facebook SDK and graph API

This is after I get a valid auth token.

    Bundle params = new Bundle();
    params.putString("source", AssetsUtils.getExportMoviePath(this)); ///data/user/0/com.bundlecomp.appname/files/export.mp4
    params.putString("name", "TestName");
    params.putString("title", "TestTitle");
    params.putString("filename", "export.mp4");
    params.putString("description", "Created with http://wwww.test.tu");
    Log.d(TAG, "Posting on user wall");
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/videos",
            params,
            HttpMethod.POST,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    Log.d(TAG, "GOT response from facebook. Error : " + response.getRawResponse());
                    Log.d(TAG, "GOT response from facebook. Error : " + response.getError());
                    Log.d(TAG, "GOT response from facebook. Resp : " + response);

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            finish();
                            Log.d(TAG, "Posted");

                        }
                    });
                }
            }
    ).executeAsync();

However I get the following error:

{ Response: responseCode: 400, graphObject: null, error: {
HttpStatus: 400, errorCode: 390, errorType: OAuthException,
errorMessage: There was a problem uploading your video file. Please try again. } }

What am I doing wrong ?

Upvotes: 0

Views: 189

Answers (1)

Antzi
Antzi

Reputation: 13444

Here is what I used:

   Bundle params = new Bundle();
    try {
        params.putByteArray("video.mp4", Files.toByteArray(new File(AssetsUtils.getExportMoviePath(this))));
    } catch (IOException pE) {
        pE.printStackTrace();
    }
    params.putString("name", "TestName");
    params.putString("title", "TestTitle");
    params.putString("filename", "video.mp4");
    params.putString("description", "Created with http://wwww.test.tu");
    Log.d(TAG, "Posting on user wall");
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/videos",
            params,
            HttpMethod.POST,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                     runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            finish();
                            Log.d(TAG, "Posted");

                        }
                    });
                }
            }
    ).executeAsync();

Upvotes: 1

Related Questions