Forum Discussion

Saikiran's avatar
Saikiran
Explorer | Level 3
9 years ago

I have a CSV file with headers/fields?

 

OwnerId,FirstName,LastName,MailingStreet,MailingCity,MailingState,MailingPostalCode,MailingCountry,Phone,RecordTypeId,Email,Campaign,IF_Local_Leader__c
005A0000001EHjd,jan 16 test for ACTON,kumar,,,,,,,012A0000000K4y8IAC,Test10@gmail.com,701q0000000K2Us,TRUE
005A0000001EHjd,Jan 16 If local check,Kumat,,,,,,,012A0000000K4y8IAC,testiflocal@gmail.com,701q0000000K2Us,TRUE
005A0000001EHjd,gowtham,test,,,,,,,012A0000000K4y8IAC,testacton123@gmail.com,701q0000000K2Us,TRUE

 I have a CSV file with headers/fields as like above

 

but when i preview/open the file in the dropbox it is coming in different format?

like

{"type":"Buffer","data":[79,119,110,101,114,73,100,44,70,105,114,115,116,78,97,109,101,44,76,97,115,116,78,97,109,101,44,77,97,105,108,105,110,103,83,116,114,101,101,116,44,77,97,105,108,105,110,103,67,105,116,121,44,77,97,105,108,105,110,103]

 

 

scenario is like this?

1. I used dropbox API to connect from Nodejs.

2. successfully connected.

3. stored a file in Apps folder.

4. created a folder there.

5. drop some files(csv files) in that.

6. but when i try to open the csv files the format is completely changed ..

it is giving like

types: buffer

data: [,,,,,,]

 

....

 

Please hlep on this.

6 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    I'll be happy to help with any issues you're having with the Dropbox API, but I'll need some more information. Please reply with:

    - the name and version of the SDK/library you are using, if any
    - the relevant code snippet(s)
  • Saikiran's avatar
    Saikiran
    Explorer | Level 3
    9 years ago

    Thanks .

    My sdk version 1.3.14

     

    My code is given below, here am reading my local csv file and passing that value to the dropbox.

    i.e, upload a csv file to dropbox.

     

    var node_dropbox = require('node-dropbox');
    var fs = require('fs');

     

    var api = node_dropbox.api('<REDACTED>'); //my access token


    var f = '/Users/saikiran/Downloads/ifg_localleader_contacts.csv'; // my local csv file
    fs.readFile(f, function (err, data) {
    if (err) { throw err; }

     

    api.createFile('12.csv',data, function(err, res) {
    console.log(err);
    });
    });



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

    I've redacted the access token in your previous post, but since it was visible for some time, you should really disable that access token to make sure no one else can access your account.

     

    I believe the bug is in the node-dropbox library, which is written by a third-party. This line seems suspect: https://github.com/g33kidd/node-dropbox/blob/master/lib/node_dropbox.js#L96. I believe setting json to true means that the requests library attempts to JSON-serialize your Buffer. I would recommend setting that to false instead.

     

    Note also that this library appears to still use API v1, which has been deprecated and is due to be fully turned off in June: https://blogs.dropbox.com/developers/2016/06/api-v1-deprecated/. You might prefer to use the official Dropbox JavaScript SDK, which uses API v2: https://github.com/dropbox/dropbox-sdk-js.

  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago
    Actually, I made an assumption about the library you're using... but I see that you said you were using version 1.3.14, but the library I mentioned has a current version of 0.1.8.

    Could it be that you're using a different library?
  • Saikiran's avatar
    Saikiran
    Explorer | Level 3
    9 years ago

    Thanks Steve.

     

    My issue is resolved with using dbox module in node.

     

    Thanks for your time.

  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago
    It appears to me that the dbox module also uses the deprecated API v1. (If this code doesn't need to work past June, that's okay to ignore.)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from 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!