Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7719587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:27:10+00:00 2026-06-01T03:27:10+00:00

I wish upload a video on dailymotion with c# code , but dailymotion doesn’t

  • 0

I wish upload a video on dailymotion with c# code , but dailymotion doesn’t provide c# code to upload video with c#.

I search on dailymotion documentation api and i found this not explicit curl code :

curl -F 'access_token=...' \
     -F 'url=http://upload-02.dailymotion.com/files/5ccb48b8e8aef3fcb8959739f993e1b9.3gp' \
     https://api.dailymotion.com/me/videos

and i tryed to transpose but it’s not working:

 string contentFile = "c:\name_of_my_video_file.flv";
            byte[] byteArray = Encoding.ASCII.GetBytes(contentFile);
            MemoryStream fs = new MemoryStream(byteArray);

            // Provide the WebPermission Credintials
            // Create a request using a URL that can receive a post. 
            string uri = "https://api.dailymotion.com/me/videos";
            WebRequest request = WebRequest.Create(uri);
            // Set the Method property of the request to POST.
            request.Method = "POST";
            request.Credentials = new NetworkCredential("logindailymotion","passworddailymotion");

            // Create POST data and convert it to a byte array.
            string postData = "access_token=my_api_key&url=http://upload-02.dailymotion.com/files/name_of_my_video_file.flv";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;
            // Get the request stream.

            // Notify the server about the size of the uploaded file
            request.ContentLength = fs.Length;

            // The buffer size is set to 2kb
            int buffLength = 2048;
            byte[] buff = new byte[buffLength];
            int contentLen;

            // Opens a file stream (System.IO.FileStream) to read the file to be uploaded
            //FileStream fs = fileInf.OpenRead();

            try
            {
                // Stream to which the file to be upload is written
                Stream strm = request.GetRequestStream();

                // Read from the file stream 2kb at a time
                contentLen = fs.Read(buff, 0, buffLength);

                // Till Stream content ends
                while (contentLen != 0)
                {
                    // Write Content from the file stream to the FTP Upload Stream
                    strm.Write(buff, 0, contentLen);
                    contentLen = fs.Read(buff, 0, buffLength);
                }

                // Close the file stream and the Request Stream
                strm.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

Is there a better documentation for c# code ?

Is somebody has the correct code ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:27:12+00:00Added an answer on June 1, 2026 at 3:27 am

    I created a complete example to answer your question and upload a video. It is available on GitHub now.

    Edit: I used API information available explaining how to do their OAuth Authentication and Video Publishing.

    Here is all the code except for the objects that are deserialized from JSON:

    Code

        static void Main(string[] args)
        {
            var accessToken = GetAccessToken();
            Authorize(accessToken);
    
            Console.WriteLine("Access token is " + accessToken);
    
            var fileToUpload = @"C:\Program Files\Common Files\Microsoft Shared\ink\en-US\join.avi";
    
            Console.WriteLine("File to upload is " + fileToUpload);
    
            var uploadUrl = GetFileUploadUrl(accessToken);
    
            Console.WriteLine("Posting to " + uploadUrl);
    
            var response = GetFileUploadResponse(fileToUpload, accessToken, uploadUrl);
    
            Console.WriteLine("Response:\n");
    
            Console.WriteLine(response + "\n");
    
            Console.WriteLine("Publishing video.\n");
            var uploadedResponse = PublishVideo(response, accessToken);
    
            Console.WriteLine(uploadedResponse);
    
            Console.WriteLine("Done. Press enter to exit.");
            Console.ReadLine();
        }
    
        private static UploadResponse GetFileUploadResponse(string fileToUpload, string accessToken, string uploadUrl)
        {
            var client = new WebClient();
            client.Headers.Add("Authorization", "OAuth " + accessToken);
    
            var responseBytes = client.UploadFile(uploadUrl, fileToUpload);
    
            var responseString = Encoding.UTF8.GetString(responseBytes);
    
            var response = JsonConvert.DeserializeObject<UploadResponse>(responseString);
    
            return response;
        }
    
        private static UploadedResponse PublishVideo(UploadResponse uploadResponse, string accessToken)
        {
            var request = WebRequest.Create("https://api.dailymotion.com/me/videos?url=" + HttpUtility.UrlEncode(uploadResponse.url));
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", "OAuth " + accessToken);
    
            var requestString = String.Format("title={0}&tags={1}&channel={2}&published={3}",
                HttpUtility.UrlEncode("some title"),
                HttpUtility.UrlEncode("tag1"),
                HttpUtility.UrlEncode("news"),
                HttpUtility.UrlEncode("true"));
    
            var requestBytes = Encoding.UTF8.GetBytes(requestString);
    
            var requestStream = request.GetRequestStream();
    
            requestStream.Write(requestBytes, 0, requestBytes.Length);
    
            var response = request.GetResponse();
    
            var responseStream = response.GetResponseStream();
            string responseString;
            using (var reader = new StreamReader(responseStream))
            {
                responseString = reader.ReadToEnd();
            }
    
            var uploadedResponse = JsonConvert.DeserializeObject<UploadedResponse>(responseString);
            return uploadedResponse;
        }
    
        private static string GetAccessToken()
        {
            var request = WebRequest.Create("https://api.dailymotion.com/oauth/token");
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
    
            var requestString = String.Format("grant_type=password&client_id={0}&client_secret={1}&username={2}&password={3}",
                HttpUtility.UrlEncode(SettingsProvider.Key),
                HttpUtility.UrlEncode(SettingsProvider.Secret),
                HttpUtility.UrlEncode(SettingsProvider.Username),
                HttpUtility.UrlEncode(SettingsProvider.Password));
    
            var requestBytes = Encoding.UTF8.GetBytes(requestString);
    
            var requestStream = request.GetRequestStream();
    
            requestStream.Write(requestBytes, 0, requestBytes.Length);
    
            var response = request.GetResponse();
    
            var responseStream = response.GetResponseStream();
            string responseString;
            using (var reader = new StreamReader(responseStream))
            {
                responseString = reader.ReadToEnd();
            }
    
            var oauthResponse = JsonConvert.DeserializeObject<OAuthResponse>(responseString);
    
            return oauthResponse.access_token;
        }
    
        private static void Authorize(string accessToken)
        {
            var authorizeUrl = String.Format("https://api.dailymotion.com/oauth/authorize?response_type=code&client_id={0}&scope=read+write+manage_videos+delete&redirect_uri={1}",
                HttpUtility.UrlEncode(SettingsProvider.Key),
                HttpUtility.UrlEncode(SettingsProvider.CallbackUrl));
    
            Console.WriteLine("We need permissions to upload. Press enter to open web browser.");
            Console.ReadLine();
    
            Process.Start(authorizeUrl);
    
            var client = new WebClient();
            client.Headers.Add("Authorization", "OAuth " + accessToken);
    
            Console.WriteLine("Press enter once you have authenticated and been redirected to your callback URL");
            Console.ReadLine();
        }
    
        private static string GetFileUploadUrl(string accessToken)
        {
            var client = new WebClient();
            client.Headers.Add("Authorization", "OAuth " + accessToken);
    
            var urlResponse = client.DownloadString("https://api.dailymotion.com/file/upload");
    
            var response = JsonConvert.DeserializeObject<UploadRequestResponse>(urlResponse).upload_url;
    
            return response;
        }
    

    Again, I put it on GitHub.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to use the following regex for validating a file-upload: /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(ext)$/ But
I wish to upload from my Flash Application (AS3) to imageshacks XML API. I
I wish to search a database table on a nullable column. Sometimes the value
I wish to test a function that will generate lorem ipsum text, but it
I wish upload a file into my iphone app via ftp ( wifi connection
I am using ZipOutputStream from SharpZipLib and I wish to upload the zipped contents
I wish to create an ASP.NET web application that allows upload of files up
I'm using the Magento Soap Api to upload pictures of products. I can't seem
I allow users to upload a photo. This photo is stored using paperclip. The
I wish to use Google custom search and in particular would like to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.