Created
November 30, 2012 15:02
-
-
Save liluo/4176272 to your computer and use it in GitHub Desktop.
Douban API v2 上传图片 length mismatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Faraday::Parts::FilePart | |
def initialize(boundary, name, io) | |
file_length = io.respond_to?(:length) ? io.length : File.size(io.local_path) | |
@head = build_head(boundary, name, io.original_filename, io.content_type, file_length, | |
io.respond_to?(:opts) ? io.opts : {}) | |
@length = @head.length + file_length | |
@io = CompositeReadIO.new(StringIO.new(@head), io, StringIO.new("\r\n")) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment