1

I'm trying to upload an xml file that located on my server to Dropbox.

            Session["AccessToken"] = "xxxxxxxxxxxxxxxxxxx";
            if (Session["AccessToken"] == null)
            {
                Response.Write("Error. Access token not found.<br /><a href=\"/\">Try again</a>.");
                return;
            }
            var token = Session["AccessToken"].ToString();
            string serverPath = "/" + System.IO.Path.GetFileName(FileUpload1.FileName);
           // you can upload to any folder:
            // serverPath = "/folder_name/" + System.IO.Path.GetFileName(FileUpload1.FileName);
            // folder_name - should exist in dropbox
            var fileInfo = UniValue.Empty;
            fileInfo["path"] = serverPath;
            fileInfo["mode"] = "overwrite";
            fileInfo["autorename"] = true;
            fileInfo["mute"] = false;
            var result = OAuthUtility.Post
            (
              "https://content.dropboxapi.com/2/files/upload",
              new HttpParameterCollection
    { 
      { FileUpload1.PostedFile } 
    },
              headers: new NameValueCollection { { "Dropbox-API-Arg", fileInfo.ToString() } },
              contentType: "application/octet-stream",
              authorization: String.Format("Bearer {0}", token)
            );

the code above works perfectly if I use the FileUpload control. but in my case, I want to upload the file that is located in my server e.g. "https://www.example.com/file.xml" into my dropbox.. I tried to use the file upload control and assign the value into the control, but I found out that I can't do it because of the web browser security. the problem exactly at ( FileUpload1.PostedFile ) .. how can I use the PostedFile property without using the FileUpload control ? Is there anyway to go around this ? thanks in advance.

Dan
  • 11
  • 1
  • Maybe duplicate to [Uploading file to Dropbox with Devdefined OAuth library](http://stackoverflow.com/questions/8663974/uploading-file-to-dropbox-with-devdefined-oauth-library) – H.G. Sandhagen Jan 07 '17 at 20:49

0 Answers0