cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

docs contain invalid chars

docs contain invalid chars

bradoyler
New member | Level 2

using JS sdk method paperDocsDownload({ doc_id, export_format: 'html' }) and certain character (m-dash, curly quotes) come thru as â.

 

The test document is here: https://paper.dropbox.com/doc/test-paper-doc-S7sSIlM2E0g6p3OXhhts4 

 

Also the project I'm working on is here: https://github.com/bradoyler/paper2json

1 Accepted Solution

Accepted Solutions

Re: docs contain invalid chars

Greg-DB
Dropboxer

Thanks!

 

I was able to reproduce the issue. It looks like it is a matter of encoding it properly. You can do so like this:

 

new Buffer(doc.fileBinary, 'binary').toString()

I'll ask the team to look into whether or not the SDK should/can do that for you though.

View solution in original post

9 Replies 9

Re: docs contain invalid chars

Greg-DB
Dropboxer
Thanks! Can you share the rest of the problematic code though? Thanks in advance!

Re: docs contain invalid chars

Greg-DB
Dropboxer
The 'paper2json' GitHub link you shared is a 404 for me. (Perhaps it's not publicly accessible?)

In any case, can you share just the code snippet(s) needed to reproduce the 'â' issue?

When I download the data to an html file using `URL.createObjectURL(response.fileBlob)` the resulting html file shows the correct characters.

Re: docs contain invalid chars

Greg-DB
Dropboxer
The repo is available now, and it looks like you're running in node and not browser JavaScript like I was testing with. I'll try your code in node. Thanks!

Re: docs contain invalid chars

bradoyler
New member | Level 2

Re: docs contain invalid chars

bradoyler
New member | Level 2

interestingly, I dont see the malformed html when I use the http api via: 

curl -X POST https://api.dropboxapi.com/2/paper/docs/download \
    --header "Authorization: Bearer xxyyzzzzzz" \
    --header "Dropbox-API-Arg: {\"doc_id\": \"S7sSIlM2E0g6p3OXhhts4\",\"export_format\": \"html\"}"

Re: docs contain invalid chars

Greg-DB
Dropboxer

Thanks!

 

I was able to reproduce the issue. It looks like it is a matter of encoding it properly. You can do so like this:

 

new Buffer(doc.fileBinary, 'binary').toString()

I'll ask the team to look into whether or not the SDK should/can do that for you though.

View solution in original post

Re: docs contain invalid chars

bradoyler
New member | Level 2

Doh! You're right.

Proper way to do this in Node 6+ is like this:

Buffer.from(doc.fileBinary, 'binary').toString()

But yea, I can't think of a reason why an SDK user would want different behavior from the HTTP API.

Thanks!

 

Re: docs contain invalid chars

Greg-DB
Dropboxer
For reference, that is no longer necessary with the latest version of the SDK, v.3.x. You can just use fileBinary directly.

Re: docs contain invalid chars

Greg-DB
Dropboxer
Unfortunately, this caused a different issue. Please upgrade to v4.0.0 and use the Buffer workaround again. Apologies for the bother.
Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    bradoyler New member | Level 2
What do Dropbox user levels mean?
Need more support?