You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
kmsbs
7 years agoExplorer | Level 4
My uploaded files on Dropbox are 0 bytes/ empty.
I have an app,In this app we are using dropbox v2 for upload or download a file.
I uplaoded a file but it shown as a empty file and 0 byte.
Jane
Dropbox Staff
As I’d like to help you on the issue you’ve experienced as much as possible, can you clarify whether you’re uploading your file using the web Uploader, your mobile, through your desktop or if you’ve created your own app that’s uploading your files to the Dropbox folder?
Once I have a bit more info, I’ll make sure to send you the most relevant next steps here. Thanks again & I’ll be awaiting your next post on this discussion!
kmsbs
7 years agoExplorer | Level 4
this is my code :
public class UploadTask extends AsyncTask {
private DbxClientV2 dbxClient;
private File file;
@SuppressLint("StaticFieldLeak")
private Context context;
ProgressDialog dialog;
UploadTask(DbxClientV2 dbxClient, File file, Context context) {
this.dbxClient = dbxClient;
this.file = file;
this.context = context;
}
@Override
protected Object doInBackground(Object[] params) {
try {
// Log.e("async read",ReadFile(file));
InputStream inputStream = new FileInputStream(file);
dbxClient.files().uploadBuilder("/" +file.getName()) //Path in the user's Dropbox to save the file.
.withMode(WriteMode.OVERWRITE) //always overwrite existing file
.uploadAndFinish(inputStream);
Log.e("Upoad", "" + dbxClient.files().uploadBuilder("/" + file.getName()) //Path in the user's Dropbox to save the file.
.withMode(WriteMode.OVERWRITE) //always overwrite existing file
.uploadAndFinish(inputStream));
} catch (DbxException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
DownloadActivity.dialog.dismiss();
Toast.makeText(context, "File uploaded successfully", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
public static String ReadFile(File file){
String line = null;
try {
FileInputStream fileInputStream = new FileInputStream (file);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuilder stringBuilder = new StringBuilder();
while ( (line = bufferedReader.readLine()) != null )
{
stringBuilder.append(line + System.getProperty("line.separator"));
}
fileInputStream.close();
line = stringBuilder.toString();
bufferedReader.close();
}
catch(FileNotFoundException ex) {
Log.d("FileNotFoundException", ex.getMessage());
}
catch(IOException ex) {
Log.d("IOException", ex.getMessage());
}
return line;
}
}
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 9 days agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!