<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to check folder exist or not and how to upload image using URL using C# in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291261#M17804</link>
    <description>&lt;P&gt;Thank you so much for the help. Using await and removing result worked for me.&lt;/P&gt;&lt;PRE&gt;try
            {
                await client.Files.GetMetadataAsync(path);
            }
            catch (ApiException&amp;lt;Dropbox.Api.Files.GetMetadataError&amp;gt; e)
            {
                if (e.ErrorResponse.IsPath &amp;amp;&amp;amp; e.ErrorResponse.AsPath.Value.IsNotFound)
                {
                    Console.WriteLine("Nothing found at path.");
                }
                else
                {
                    // different issue; handle as desired
                    Console.WriteLine(e);
                }
            }&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Aug 2018 18:42:27 GMT</pubDate>
    <dc:creator>JayPatel1992</dc:creator>
    <dc:date>2018-08-14T18:42:27Z</dc:date>
    <item>
      <title>How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291082#M17792</link>
      <description>&lt;P&gt;Hello there,&amp;nbsp;&lt;BR /&gt;I am using Dropbox.Api. I want to check if folder exist or not. I tired using try and catch block but I think there should be a better way for doing this.&lt;BR /&gt;Here is my try catch block:&lt;/P&gt;&lt;PRE&gt;try
            {
                var isFolder = client.Files.GetMetadataAsync(path).Result.IsFolder;
            }
            catch (Exception e)
            {
                // TODO Auto-generated catch block
                if (e.InnerException.Message == "path/not_found/...")
                {
                  var folder = CreateFolder(client, path);
                }
            }&lt;/PRE&gt;&lt;P&gt;Also I want to upload image to dropbox using image URL.&lt;BR /&gt;Here is what I am doing, but didn't upload any image nor giving any error.&lt;/P&gt;&lt;P&gt;Please help me with this.&lt;/P&gt;&lt;PRE&gt;List&amp;lt;Images&amp;gt; fiveElements = Images.GetRange(0, 5);
            foreach (var image in fiveElements)
            {
                using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(image.ImageURL)))
                {
                    string fileName = image.ImageURL;
                    var response = await client.Files.UploadAsync(path + "/" + fileName, WriteMode.Overwrite.Instance, body: stream);
                    Console.WriteLine("Uploaded Id {0} Rev {1}", response.Id, response.Rev);
                }
            }&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 09:11:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291082#M17792</guid>
      <dc:creator>JayPatel1992</dc:creator>
      <dc:date>2019-05-29T09:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291141#M17795</link>
      <description>&lt;P&gt;Using the&amp;nbsp;GetMetadataAsync method is the right way to check for the existence of something at a particular path. You're correct that there is a more native way to to the error handling though. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;catch (ApiException&amp;lt;Dropbox.Api.Files.GetMetadataError&amp;gt; e)
{
    if (e.ErrorResponse.IsPath &amp;amp;&amp;amp; e.ErrorResponse.AsPath.Value.IsNotFound) {
        Console.WriteLine("Nothing found at path.");
    } else {
        // different issue; handle as desired
        Console.WriteLine(e);
    }
}&lt;/PRE&gt;
&lt;P&gt;For your uploading code, it appears you're getting the bytes for the URL string itself, instead of downloading the actual data located at that URL. You should update your code to download the actual bytes, and then pass them to the&amp;nbsp;Dropbox upload method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, as long as the URL is publicly accessible, you can pass the URL directly to the&amp;nbsp;SaveUrlAsync method to have&amp;nbsp;Dropbox do the downloading for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_SaveUrlAsync_1.htm" target="_blank"&gt;https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_SaveUrlAsync_1.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:21:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291141#M17795</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-08-14T15:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291149#M17798</link>
      <description>&lt;P&gt;Thank you @Greg K. for the help. That's really quick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I am new to this coding stuff, it would be good if I have example for&amp;nbsp;&lt;SPAN&gt;FilesUserRoutes&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SaveUrlAsync Method which explains in detail.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And does the try block is good ? because I tired your catch block and it thows me out of the method and goes into catch(Exception e) of parent method.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:39:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291149#M17798</guid>
      <dc:creator>JayPatel1992</dc:creator>
      <dc:date>2018-08-14T15:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291191#M17801</link>
      <description>&lt;P&gt;I don't have a sample available for that unfortunately. The basic idea is to call&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_SaveUrlAsync_1.htm" target="_blank"&gt;SaveUrlAsync&lt;/A&gt; with the 'path' for where you want to save the file, and the 'url' for the hosted file data to save.&amp;nbsp;Then, if the&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_Files_SaveUrlResult.htm" target="_blank"&gt;SaveUrlResult&lt;/A&gt; gives you an&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_Files_SaveUrlResult_AsyncJobId.htm" target="_blank"&gt;AsyncJobId&lt;/A&gt;, call&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_SaveUrlCheckJobStatusAsync_1.htm" target="_blank"&gt;SaveUrlCheckJobStatusAsync&lt;/A&gt; ocasionally to check on the job status.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give that a try and let me know if something isn't working as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And yes, using the try/catch pattern is a good way to do that&amp;nbsp;existence check.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 16:51:03 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291191#M17801</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-08-14T16:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291197#M17802</link>
      <description>&lt;P&gt;Didn't get much about SvaeUrlAsync but I used this and it worked perfectly.&lt;/P&gt;&lt;PRE&gt;List&amp;lt;Images&amp;gt; fiveElements = Images.GetRange(0, 5);
            foreach (var image in fiveElements)
            {
                WebClient webclient = new WebClient();
                var stream = new MemoryStream(webclient.DownloadData(image.ImageURL));
                var fileName = "Test1.jpg";
                var response = await client.Files.UploadAsync(path + "/" + fileName, WriteMode.Overwrite.Instance, true, body: stream);
            }&lt;/PRE&gt;&lt;P&gt;And for try catch I used your code but not working well as it throws me out of this method and goes to catch(Exception e) of parent method.&lt;/P&gt;&lt;PRE&gt;try
            {
                await client.Files.GetMetadataAsync(path);
            }
            catch (ApiException&amp;lt;Dropbox.Api.Files.GetMetadataError&amp;gt; e)
            {
                if (e.ErrorResponse.IsPath &amp;amp;&amp;amp; e.ErrorResponse.AsPath.Value.IsNotFound)
                {
                    Console.WriteLine("Nothing found at path.");
                }
                else
                {
                    // different issue; handle as desired
                    Console.WriteLine(e);
                }
            }&lt;/PRE&gt;&lt;P&gt;Please let me know where I am going wrong.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 18:43:43 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291197#M17802</guid>
      <dc:creator>JayPatel1992</dc:creator>
      <dc:date>2018-08-14T18:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291254#M17803</link>
      <description>I think that's because you're using '.Result' instead of 'await'. That's more of a general C# exception handling matter though, so I can't provide much insight there. You'll probably need to change how you structure your exception handling, or switch to using 'await'.</description>
      <pubDate>Tue, 14 Aug 2018 18:21:14 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291254#M17803</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-08-14T18:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to check folder exist or not and how to upload image using URL using C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291261#M17804</link>
      <description>&lt;P&gt;Thank you so much for the help. Using await and removing result worked for me.&lt;/P&gt;&lt;PRE&gt;try
            {
                await client.Files.GetMetadataAsync(path);
            }
            catch (ApiException&amp;lt;Dropbox.Api.Files.GetMetadataError&amp;gt; e)
            {
                if (e.ErrorResponse.IsPath &amp;amp;&amp;amp; e.ErrorResponse.AsPath.Value.IsNotFound)
                {
                    Console.WriteLine("Nothing found at path.");
                }
                else
                {
                    // different issue; handle as desired
                    Console.WriteLine(e);
                }
            }&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 18:42:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-check-folder-exist-or-not-and-how-to-upload-image-using/m-p/291261#M17804</guid>
      <dc:creator>JayPatel1992</dc:creator>
      <dc:date>2018-08-14T18:42:27Z</dc:date>
    </item>
  </channel>
</rss>

