Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Vivek S.3's avatar
Vivek S.3
New member | Level 2
9 years ago
Solved

File Naming

Hi,

 

I'm using the nodejs SDK and I notice that when using the filesUpload method, file names seem to be get clipped short. For example, I have a file that is uploaded to the path - 

/test/some_folder/This Is A Test File - 123456 - 09/23/2016 - blah - blah.pdf

 

When I go into the dropbox explorer UI I see - /test/some_folder/2016 - blah - blah.pdf

 

Is there a a way to prevent this name-shortening?

  • Steve M.'s avatar
    Steve M.
    9 years ago

    Oh, it looks like things are working correctly then.

     

    A forward slash is the path separator, so the path /foo/bar/baz means a file named "baz" in a folder called "bar" within a folder called "foo".

     

    The path you're passing has six slashes, and it seems like you expect four of them to be path separators and two of them to not be. How would Dropbox know which were which?

     

    https://www.dropbox.com/help/145 may help. It goes over some of the restrictions in characters that make up paths in Dropbox.

5 Replies

Replies have been turned off for this discussion
  • Vivek S.3's avatar
    Vivek S.3
    New member | Level 2
    9 years ago

    Okay, I think it's the slashes. I replaced them with hyphens and it seemed to work. The question now is, how do I get forward slashes into the filenames?

  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago

    I can't reproduce the issue. Could you share your code? For reference, here is the code I used that worked successfully. (The file was in the expected location as observed on dropbox.com.)

     

    const Dropbox = require('dropbox');
    const dbx = new Dropbox({ accessToken: '<REDACTED>' });
    dbx.filesUpload({
    path: '/test/some_folder/This Is A Test File - 123456 - 09/23/2016 - blah - blah.pdf',
    contents: "Hello, World!"
    }).then((response) => { console.log(response); }).catch((error) => { console.log(error); });
  • Vivek S.3's avatar
    Vivek S.3
    New member | Level 2
    9 years ago

    Hi Steve,

     

    Here is my code - 

     

     

    let dropboxConnector = require('./connectors/dropbox_connector');
    // This is my dbx instance with the token.
    
    dropboxConnector.filesUpload({
        contents: "Test",
        path: '/dev/test/test_folder/test name - 1234 - xof - 12/12/2016 - test',
        mute: true,
    }).then((res) => {
        console.log(res);
    });

     

    I just re-ran this and what ends up happening here is I get a folder structure (indicated by >) like this on dropbox - 

     

    dev > test > test_folder > test name - 1234 - xof - 12 > 12 > 2016 - test

     

    with 2016 - test being written as the filename and test name - 1234 - xof - 12 being written as a folder.

     

    My expectation is - 

     

    dev > test > test_folder > test name - 1234 - xof -12/12/2016 - test

     

    with "test name - 1234 - xof -12/12/2016 - test" being the file name.

     

     

  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago

    Oh, it looks like things are working correctly then.

     

    A forward slash is the path separator, so the path /foo/bar/baz means a file named "baz" in a folder called "bar" within a folder called "foo".

     

    The path you're passing has six slashes, and it seems like you expect four of them to be path separators and two of them to not be. How would Dropbox know which were which?

     

    https://www.dropbox.com/help/145 may help. It goes over some of the restrictions in characters that make up paths in Dropbox.

  • Vivek S.3's avatar
    Vivek S.3
    New member | Level 2
    9 years ago

    Steve,

     

    Thanks. That makes sense. 

     

    Vivek

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

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!