tumblr / tumblr.js

JavaScript client for the Tumblr API
https://tumblr.github.io/tumblr.js/
Apache License 2.0
648 stars 120 forks source link

native_inline_images option borks #48

Closed positlabs closed 8 years ago

positlabs commented 8 years ago

Using native_inline_images option for photo posts is failing.

client.photo(req.body.blogname, {
        source: 'https://img.buzzfeed.com/buzzfeed-static/static/2014-04/enhanced/webdr03/4/16/enhanced-26552-1396642701-1.jpg?no-auto',
        native_inline_images: true,
    }, function(){});

Stack trace:

_http_outgoing.js:443
    throw new TypeError('first argument must be a string or Buffer');
    ^

TypeError: first argument must be a string or Buffer
    at ClientRequest.OutgoingMessage.write (_http_outgoing.js:443:11)
    at Request.write (/Volumes/space/server/node_modules/request/request.js:1371:25)
    at FormData.ondata (stream.js:31:26)
    at emitOne (events.js:90:13)
    at FormData.emit (events.js:182:7)
    at FormData.CombinedStream.write (/Volumes/space/server/node_modules/combined-stream/lib/combined_stream.js:118:8)
    at FormData.CombinedStream._pipeNext (/Volumes/space/server/node_modules/combined-stream/lib/combined_stream.js:106:8)
    at FormData.CombinedStream._getNext (/Volumes/space/workspace/server/node_modules/combined-stream/lib/combined_stream.js:79:10)
    at FormData.CombinedStream._pipeNext (/Volumes/space/workspace/server/node_modules/combined-stream/lib/combined_stream.js:107:8)
    at FormData.CombinedStream._getNext (/Volumes/space/server/node_modules/combined-stream/lib/combined_stream.js:79:10)
positlabs commented 8 years ago

Maybe I misunderstood what this option is for. The docs are super vague, but it seems like this is only for html images and not photo posts.

Convert any external image URLs to Tumblr image URLs

Maybe it's failing because I'm not supplying a caption? Either way, I don't think it should bork if caption is missing.

nemesisqp commented 8 years ago

I got this problem today, solution: native_inline_images: 'true' work with html format, don't work with markdown, what a shame >_<

kmck commented 8 years ago

@positlabs: yeah, the documentation for native_inline_images could be a little clearer. it only applies to images in the body/caption field of posts, where we consider images "inline" with the text caption as opposed to being the front-and-center media content of the post.

for the case you're describing, what you're trying to do, you shouldn't need native_inline_images in the first place; source: 'https://img.buzzfeed.com/buzzfeed-static/static/2014-04/enhanced/webdr03/4/16/enhanced-26552-1396642701-1.jpg?no-auto' should be enough to create a photo post from that external image.

@nemesisqp: you're right that native_inline_images doesn't currently work for markdown posts. sorry!

closing this for now since it's behaving correctly.