<?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: [API] Can't download or overwrite a file after uploading it 1 time(android) (have to reload the in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302200#M18275</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;package com.example.admin.prankclient;

import android.os.AsyncTask;
import android.util.Log;

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.files.FileMetadata;
import com.dropbox.core.v2.files.UploadErrorException;
import com.dropbox.core.v2.files.WriteMode;

import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;

import static android.support.constraint.Constraints.TAG;

public class uploadFile {
    private static final String ACCESS_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    private DbxRequestConfig config = null;
    DbxClientV2 client = null;
    private String command;
    private String foldername;
    uploadFile(String command, String foldername)
    {
        // Create Dropbox client
        config = new DbxRequestConfig("PrankClient");
        client = new DbxClientV2(config, ACCESS_TOKEN);
        this.command=command;
        this.foldername=foldername;
        Log.d(TAG,"------------------FIRST PHASE");
        new Uploading().execute();
        //Uploading run = new Uploading();
        //run.execute();

    }

    private class Uploading extends AsyncTask {


        @Override
        protected void onPostExecute(Object o) {
            Log.d(TAG,"------------------END");
            super.onPostExecute(o);
        }

        @Override
        protected Object doInBackground(Object[] objects) {
            Log.d(TAG,"------------------background");
            try {
                //String Dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/PrankClient";
                //InputStream in = new FileInputStream(Dir + "/Check.txt");
                InputStream in = new ByteArrayInputStream(command.getBytes(Charset.forName("UTF-8"))) ;

                FileMetadata metadata = client.files().uploadBuilder(foldername).withMode(WriteMode.OVERWRITE).uploadAndFinish(in);

                in.close();
            }
            catch (FileNotFoundException fne)
            {
                fne.printStackTrace();
            }
            catch (IOException ioe) {
                ioe.printStackTrace();
            } catch (UploadErrorException e) {
                e.printStackTrace();
            } catch (DbxException e) {
                e.printStackTrace();
            }

            return null;
        }
    }
}&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Oct 2018 19:07:10 GMT</pubDate>
    <dc:creator>AzErLoc</dc:creator>
    <dc:date>2018-10-09T19:07:10Z</dc:date>
    <item>
      <title>[API] Can't download or overwrite a file after uploading it 1 time(android) (have to reload the app)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/301618#M18257</link>
      <description>&lt;P&gt;I'm not able to download or overwrite a file after uploading it 1 time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I kill the app and reload it it is ok, I can read it (download the string) but then I upload it and again I'm not able to interact with the file.&lt;BR /&gt;Here is the code of my function :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My function" style="width: 964px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/6390i1B74B8D7F9FF3247/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.PNG" alt="My function" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;My function&lt;/span&gt;&lt;/span&gt;To get the string I tried using the download funtion of the api and downloading without the api and same result.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;You can see the "Log" calls. At the first upload the 3 calls return their strings but the second time only the first one "First Phase" appear in the debuger.&lt;BR /&gt;It look like the async task doesn't start. I've also tried it without the upload function and all 3 calls appear in the debuger when I call it multiple time.&lt;BR /&gt;Sorry for my english and thank you for your help.&lt;/P&gt;&lt;P&gt;PS : I call the class with : new uploadFile(String aString, String fileName);&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:09:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/301618#M18257</guid>
      <dc:creator>AzErLoc</dc:creator>
      <dc:date>2019-05-29T09:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: [API] Can't download or overwrite a file after uploading it 1 time(android) (have to reload the</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/301931#M18270</link>
      <description>&lt;P&gt;Can you share the code as text instead of a screenshot so we can try this?&amp;nbsp;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 16:32:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/301931#M18270</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-10-08T16:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: [API] Can't download or overwrite a file after uploading it 1 time(android) (have to reload the</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302200#M18275</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;package com.example.admin.prankclient;

import android.os.AsyncTask;
import android.util.Log;

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.files.FileMetadata;
import com.dropbox.core.v2.files.UploadErrorException;
import com.dropbox.core.v2.files.WriteMode;

import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;

import static android.support.constraint.Constraints.TAG;

public class uploadFile {
    private static final String ACCESS_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    private DbxRequestConfig config = null;
    DbxClientV2 client = null;
    private String command;
    private String foldername;
    uploadFile(String command, String foldername)
    {
        // Create Dropbox client
        config = new DbxRequestConfig("PrankClient");
        client = new DbxClientV2(config, ACCESS_TOKEN);
        this.command=command;
        this.foldername=foldername;
        Log.d(TAG,"------------------FIRST PHASE");
        new Uploading().execute();
        //Uploading run = new Uploading();
        //run.execute();

    }

    private class Uploading extends AsyncTask {


        @Override
        protected void onPostExecute(Object o) {
            Log.d(TAG,"------------------END");
            super.onPostExecute(o);
        }

        @Override
        protected Object doInBackground(Object[] objects) {
            Log.d(TAG,"------------------background");
            try {
                //String Dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/PrankClient";
                //InputStream in = new FileInputStream(Dir + "/Check.txt");
                InputStream in = new ByteArrayInputStream(command.getBytes(Charset.forName("UTF-8"))) ;

                FileMetadata metadata = client.files().uploadBuilder(foldername).withMode(WriteMode.OVERWRITE).uploadAndFinish(in);

                in.close();
            }
            catch (FileNotFoundException fne)
            {
                fne.printStackTrace();
            }
            catch (IOException ioe) {
                ioe.printStackTrace();
            } catch (UploadErrorException e) {
                e.printStackTrace();
            } catch (DbxException e) {
                e.printStackTrace();
            }

            return null;
        }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Oct 2018 19:07:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302200#M18275</guid>
      <dc:creator>AzErLoc</dc:creator>
      <dc:date>2018-10-09T19:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: [API] Can't download or overwrite a file after uploading it 1 time(android) (have to reload the</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302223#M18276</link>
      <description>&lt;P&gt;Thanks! I just gave this code a try, hooking it up to a button in a sample project, and it worked fine for me when triggering it multiple times. I saw all three log statements each time.&lt;/P&gt;
&lt;P&gt;I notice you did say that 'the second time only the first one "First Phase" appear', and that 'It look like the async task doesn't start', so it does sound like the issue you're seeing has to do with running the AsyncTask itself, before the&amp;nbsp;Dropbox method is even called. (That is, since the Log call in&amp;nbsp;doInBackground is before the Dropbox call.)&amp;nbsp;I'm afraid I can't offer help with that though, since it has to do with Java/Android itself, and not the&amp;nbsp;Dropbox call in particular.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 20:39:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302223#M18276</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-10-09T20:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: [API] Can't download or overwrite a file after uploading it 1 time(android) (have to reload the</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302773#M18300</link>
      <description>&lt;P&gt;Thank you for your help. I updated my android studio and figured out what was causing this issue. It seems android studio wasn't able to process 2 async task at the same time.&lt;/P&gt;&lt;P&gt;Thank you again for your attention.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 19:33:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-Can-t-download-or-overwrite-a-file-after-uploading-it-1-time/m-p/302773#M18300</guid>
      <dc:creator>AzErLoc</dc:creator>
      <dc:date>2018-10-12T19:33:46Z</dc:date>
    </item>
  </channel>
</rss>

