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
FugetronDolphin
7 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 brows and upload file from the system and after submitted by the user this file is stored in a company Dropbox account with an automatically created folder of username
I stuck here from last 4 day and already read the various document but I didn't get any help related to my specific requirements.
Please help if anyone have the solution
Thank you in Advanced
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:
[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-DBDropbox Staff
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:
- FugetronDolphinHelpful | 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 hereNot 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-DBDropbox Staff
[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
- jboyceNew member | Level 2
I'm having the same issue. Did you ever get this solved? And if so, do you have a site I can reference for your example and maybe reach out to you on!?
About Discuss Dropbox Developer & API
Make connections with other developers797 PostsLatest Activity: 6 days ago
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 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!