Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
FugetronDolphin
8 years agoHelpful | Level 6
how to create Selective file Uploading feature in web application with Dropbox API
Hi, I am creating a web application project and use Dropbox API for storing my Users file, where I want a user to upload their file after login in there account in a website (not a dropbox) and brow...
- 8 years ago
Dropbox does offer an API you can use for uploading and listing files, among other operations. You can find everything you need to get started with the Dropbox API, including documentation, tutorials, and SDKs here:
https://www.dropbox.com/developers
I recommend using one of the official SDKs, if possible, and following the respective tutorial to get started:
https://www.dropbox.com/developers/documentation
I also recommend reading the OAuth guide to understand how the authorization process works:
- 8 years ago
[Cross-linking for reference: https://stackoverflow.com/questions/53532632/java-web-project-integration-with-dropbox-api ]
It sounds like your question is about getting the input stream for a local file. This isn't directly related to Dropbox itself, so I'm afraid I can't be of much help with this. You may be better suited by referring to general Java IO documentation or guides for interacting with the local file system.
By the way, I redacted it from your post, but for the sake of security, you should disable that access token that you posted. You can do so by revoking access to the app entirely, if the access token is for your account, here:
https://www.dropbox.com/account/connected_apps
Or, you can disable just this access token using the API:
https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
You can do so in the Java SDK itself:
Or in the API v2 Explorer if you want:
https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/revoke
Greg-DB
Dropbox Community Moderator
8 years agoDropbox does offer an API you can use for uploading and listing files, among other operations. You can find everything you need to get started with the Dropbox API, including documentation, tutorials, and SDKs here:
https://www.dropbox.com/developers
I recommend using one of the official SDKs, if possible, and following the respective tutorial to get started:
https://www.dropbox.com/developers/documentation
I also recommend reading the OAuth guide to understand how the authorization process works:
FugetronDolphin
8 years agoHelpful | Level 6
Hi Greg,
Thank you for giving suggestion But I am not getting solution for my issue .
I want pass My file to DbxUpload class After selecting from system. just same as
Drag photos/files here
Not by giving path in class.
try (InputStream in = new FileInputStream("D:/RUNNING.txt")) {
FileMetadata metadata = client.files().uploadBuilder("/RUNNING.txt")
.uploadAndFinish(in);
}
here i am stuck in how can i pass file in InputStream by clicking on choose file button and select from disc not by directly give the file path
i using this code.
1>> Click on Upload Button.
2>> Choose file from device.
3>> Pass file to DbxUpload.java class as input from MyUpload.jsp page
4>>Upload that file in Dropbox.
Here I am Attaching my code that I use for uploading the file
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>UploadFile</title> </head> <body> <a>Select to Upload</a><br><br> Select file: <br /> <form action="DbxUpload" method="Post" enctype="multipart/form-data"> <input type="file" name="file" size="70" /> <br /> <input type="submit" value="Upload File" /> </form> </body> </html>
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.ListFolderResult;
import com.dropbox.core.v2.files.Metadata;
import com.dropbox.core.v2.users.FullAccount;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
public class DbxUpload {
private static final String ACCESS_TOKEN = "<REDACTED>";
public static void main(String args[]) throws DbxException, IOException {
// Create Dropbox client
DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial", "en_US");
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
// Get current account info
FullAccount account = client.users().getCurrentAccount();
System.out.println(account.getName().getDisplayName());
// Get files and folder metadata from Dropbox root directory
ListFolderResult result = client.files().listFolder("");
while (true) {
for (Metadata metadata : result.getEntries()) {
System.out.println(metadata.getPathLower());
}
if (!result.getHasMore()) {
break;
}
result = client.files().listFolderContinue(result.getCursor());
}
// Upload "test.txt" to Dropbox
try (InputStream in = new FileInputStream("D:/RUNNING.txt")) {
FileMetadata metadata = client.files().uploadBuilder("/RUNNING.txt")
.uploadAndFinish(in);
}
}
}
please suggest what modification I need to do for solving my issue
Thank you in Advance
Regards,
Roshan
- Greg-DB8 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/53532632/java-web-project-integration-with-dropbox-api ]
It sounds like your question is about getting the input stream for a local file. This isn't directly related to Dropbox itself, so I'm afraid I can't be of much help with this. You may be better suited by referring to general Java IO documentation or guides for interacting with the local file system.
By the way, I redacted it from your post, but for the sake of security, you should disable that access token that you posted. You can do so by revoking access to the app entirely, if the access token is for your account, here:
https://www.dropbox.com/account/connected_apps
Or, you can disable just this access token using the API:
https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
You can do so in the Java SDK itself:
Or in the API v2 Explorer if you want:
https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/revoke
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!