Search code examples
c#dropboxdropbox-api

Create folder automatically during file uploading in C# using Dropbox Core API


Suppose I have a Dropbox account and I want to upload a file in the path "/Client1/2016/filename.txt". There are no folder in my dropbox account either "Client1" or "2016". My requirement is When the file will upload it will automatically create the navigation path folder "Client1/2016/" and upload the file.Is it possible? I'm using the following code for file upload-

RequestResult strReq = OAuthUtility.Put(
                                    "https://api-content.dropbox.com/1/files_put/auto/",
                                    new HttpParameterCollection
                                        {
                                            {"access_token", "AccessToken"},
                                            {"path", "filepath"},
                                            {"overwrite", "false"}, 
                                            {"autorename","false"}, 
                                            {stream}
                                        }
                                    );

Solution

  • What you're asking for is the way that the API already works. If you upload a file to the path /foo/bar, the folder /foo will be created as necessary.