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

BruceVWilcox's avatar
BruceVWilcox
Explorer | Level 4
2 months ago

Why is my local DropBox folder not readable with java?

 

I am trying to read files in DropBox folders on my Mac with java.

The following code:

String dir
= "/Users/brucewilcox/Library/CloudStorage/Dropbox/Apps/Form8949DotCom/taxdochub-forms-pdf/XXXX";
File directory = new File( dir );
boolean canRead = directory.canRead( );
String message = String.format( "canRead is: %s", canRead );
System.out.println( message );

emits

canRead is: false

 

The directory object exists, is a directory, and display an absolute path.

 

What is the root cause of this?

 

How can I fix?

 

Thank you.

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Engineer rankDropbox Engineer

    Hi BruceVWilcox,

     

    The local Dropbox folder should be readable. The issue you are encountering is most likely a local permissions issue.

     

    Since the behavior you are describing is not an error from the Dropbox API itself, we can't offer much more help with that in particular.

    • BruceVWilcox's avatar
      BruceVWilcox
      Explorer | Level 4

      It turns out that all of the individual files in the folder do not have ANY permissions for users other than me. As such the folder itself is not readable.


      I am running the java app to read the directory and files from my IntelliJ IDE. I am not sure who the user is when the IDE runs.

       

      But I am not sure why the permissions are so narrow. The folder is populated programmatically with files from a java app running in Google Cloud.

       

      What controls the file permissions?

       

      Here are code excerpts:

       

      DbxClientV2 client = getDbxClientV2( );

      try ( InputStream in = new ByteArrayInputStream( fileBytes ) ) {

      FileMetadata metadata
      = client.files( )
      .uploadBuilder( filePath )
      .uploadAndFinish( in );

      ///…

      }

      public DbxClientV2 getDbxClientV2( ) {

      String accessToken = this.getAccessToken( );

      DbxRequestConfig config
      = DbxRequestConfig
      .newBuilder( this.getAppIdentifier( ) )
      .build( );

      DbxClientV2 client = new DbxClientV2( config, accessToken );

      return client;

      }

       

      • DB-Des's avatar
        DB-Des
        Icon for Dropbox Engineer rankDropbox Engineer

        BruceVWilcox, file permissions are controlled by the user locally. Once the Dropbox app is installed and syncing is allowed, that user should have access to the contents of that Dropbox folder.

         

        Have you confirmed the file or folder you are attempting to access exists with directory.exists() function in your Java script?

    • BruceVWilcox's avatar
      BruceVWilcox
      Explorer | Level 4

      DB-Des wrote:

      Hi BruceVWilcox,

       

      The local Dropbox folder should be readable. The issue you are encountering is most likely a local permissions issue.

       

      Since the behavior you are describing is not an error from the Dropbox API itself, we can't offer much more help with that in particular.


      The folder is populated programmatically with files from a java app in Google Cloud. It turns out that the individual files do not have ANY permissions for other than me as a user. I am running the java app from my IntelliJ IDE. Not sure why the permissions are so narrow. And not sure who the user is when the IDE runs.