Using JavaScript SDK to post a video on Facebook

My current attempt involves using the following code to upload a non-resumable video from my disk to my Facebook profile with Javascript.

    FB.setAccessToken(accessToken);

    let vid = "file:///D:/videos/vid.mp4";
    //also tried with "D://videos/vid.mp4"

    FB.api(
        "/me/videos ",
        "POST",
        {
            "source": vid,
            "filename": "vid.mp4"

        },
        function (response) {
            console.log(JSON.stringify(response, null, 4));
        }
    );

However, every time I run this code, I encounter an error within seconds.

{
    "error": {
        "message": "There was a problem uploading your video file. Please try again.",
        "type": "OAuthException",
        "code": 390,
        "error_subcode": 1363030,
        "is_transient": true,
        "error_user_title": "Video Upload Time Out",
        "error_user_msg": "Your video upload timed out before it could be completed. This is probably because of a slow network connection or because the video you're trying to upload is too large. Please try again.",
        "fbtrace_id": "GwPTrdyQe7z"
    }
}

I have reviewed the documentation in search of any parameters related to timeouts but have had no success.

Can anyone offer guidance on what mistake I may be making here?

Answer №1

When using the Facebook API for file uploading, it is recommended to utilize the file-system module.

let vid = "file:///D:/videos/vid.mp4";
let videoData = require('fs').createReadStream(vid);
FB.api(
    "/me/videos ",
    "POST",
    {
        "source": videoData,
    },
    function (response) {
        console.log(JSON.stringify(response, null, 4));
    }
);

I hope this information proves helpful.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Architecting Angular for an efficient sorting directive

As a newcomer to Angular, I am exploring the best approach to accomplish a simple task. My goal is to update the order of a Project model in a database using the Angular $resource service. Here is my template structure: <table class="table table-hove ...

The SyntaxError message indicates that there was an unexpected non-whitespace character found after the JSON data when parsing it

I received an Error message: SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data Here is the code snippet: <script> $(document).ready(function () { $('.edit1').on('change', function () { ...

Undefined value recognized exclusively within conditional statements

One of the challenges I am facing involves a jQuery function designed to remove items from a cart object that is stored as a string in local storage. function removeItemFromCart(pid){ console.log("removing: ", pid) let cart = JSON.parse(l ...

Resolving the "Error: Cannot update a React state on an unmounted component" issue

I encountered a console error while attempting to navigate to a new page within my web application. Here's the error message I received: Warning: A React state update was attempted on an unmounted component, which is essentially a no-op. However, t ...

What is the ideal placement for the signOut logic in AngularJS?

Within all of my controllers, I currently have the following code that is executed when a link is clicked in the view: $scope.logout = function() { authenticationService.logout(); $scope.isAuthUser = false; delete $localStorage.selectedModel ...

How can I add a % symbol to user input in a text input field?

When utilizing a number spinner, I'm looking to include the % symbol in the input box by default. I attempted using a span, however, it places the symbol outside the box. ...

What is the best way to execute a function on the initial element of an array, then either wait, return a value, or execute the function on the subsequent element depending on a condition

I have a series of functions in Parse Cloud that interact with a node/mongo API running externally. One function retrieves an array of active user objectIds, each mapped to a message channel name arranged by distance. My goal is to process this array sta ...

Unable to set a background image sourced from API data onto a div element in Node.js

I am having trouble setting a background image to a div using the API-provided link in my CSS. Even when trying to directly access the image in Chrome, nothing seems to happen. Here's the code snippet: function getData(responseData) { var poster ...

Integrating image transitions into JavaScript

Could you provide guidance on how to create buttons from the three images within the "fadein" div in order to navigate directly to a specific jpeg? Currently, the three jpgs are displayed in a continuous loop. Thank you. ...

The b-card-img-lazy component is failing to trigger the error event when the image is not found

I am experiencing an issue with the b-card-img-lazy element. Despite its name, it is not triggering the `load` event when the image is fully loaded, nor is it firing the `error` event if the resource is not found. When the image is located, it displays cor ...

set up the router by defining the behavior for each route

My goal is to redirect the user back to the homepage when they click the browser's back arrow to return to the previous page. However, I'm facing an issue where I cannot go back to the previous page when I'm on the login page using the brow ...

The dropdown feature in Bootstrap 5 seems to be malfunctioning in Angular 12

I am facing issues while trying to implement the Bootstrap 5 dropdown in Angular 12. After installing all required packages and adding them to the angular.json file, I still cannot get it to work properly. Even after copying the example directly from the ...

Toggle the expansion and collapse of content by clicking on the header dynamically

I need to display a set of items in the UI, including a header and a list of items underneath it. I have a parent component that passes this data to a file below, resulting in a parent-child layout. I now want to implement expand/collapse functionality ...

What provides quicker performance in AngularJS: a directive or one-time binding?

I need to display a static array on a webpage without Angular watching its value. With that requirement in mind, my question is: Which method is faster: using a directive to fetch a scope variable and create an HTML element with this variable as a hard-co ...

Dispatch prop within useEffect

App.js -> <Lobbies inGame={inGame} setLobby={setLobby} userName={userName} userKey={userKey}/> Lobbies.js -> import React, { useState, useEffect } from 'react'; import firebase from 'firebase'; const Lobby = ({userKey, ...

Improving React code by using conditional statements such as IF and Else

Currently, I am delving into the world of React and have managed to devise some logic for rendering a DIV. However, upon reflection, it has become evident that there is redundancy present in my code structure and I am uncertain about how to efficiently ref ...

Adding a dynamic form to each row in a table: A step-by-step guide

https://i.sstatic.net/HctnU.jpg Hey there! I'm facing a challenge with dynamically generated rows in a form. I want to send only the inputs from the selected row when a checkbox is clicked. Can you help me figure this out? I tried using let rowForm ...

sorting in React table not functioning properly for computed column

I have a column titled 'EV/Resource ($ per oz)' that appears to not sort correctly in my react table. Instead of sorting in ascending or descending order, it randomizes the table sort. I'm unsure if I am handling this as a "calculated column ...

Fetch additional data from a table by utilizing Ajax and PHP

I have 7 data entries in my database When attempting to load the data from a table using ajax and php, I encountered an issue. After clicking the "load more" button, the data displays successfully but the "load more" button disappears. Here is my index. ...

express-ws is muting all error messages

Utilizing both express and express-ws in a node application has been causing some issues for me. It seems that express-ws is suppressing errors, making it quite challenging to debug my code effectively. To demonstrate the problem I am facing, I have simpl ...