Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEPRECATED] :mime_type option deprecated, use :content_type #881

Closed
JeffreyArtworks opened this issue Nov 15, 2017 · 6 comments

Comments

@JeffreyArtworks
Copy link

@JeffreyArtworks JeffreyArtworks commented Nov 15, 2017

		@social_product.images.first(4).each do |image|
			File.write "twitter#{@twitter_counter}.png", open(image.src).read
			@twitter_images << "./twitter#{@twitter_counter}.png"
			@twitter_counter = @twitter_counter + 1
		end
		@twitter_images = @twitter_images.map { |filename| File.new(filename) }
		@twitter_info = @twitter.update_with_media(@twitter_post, @twitter_images)

I am getting this "[DEPRECATED] :mime_type option deprecated, use :content_type" message every time I run the script. The tweet always goes through. Is there anything I need to fix to get rid of the warning?

ryanwi added a commit to ryanwi/twitter that referenced this issue Nov 20, 2017
@hmcfletch

This comment has been minimized.

Copy link

@hmcfletch hmcfletch commented Dec 12, 2017

Looks like this option was deprecated here in v1.0.2 of https://github.com/httprb/form_data. The changelog entry is here.

The changes to this gem would need to be made here.

@Rybots

This comment has been minimized.

Copy link

@Rybots Rybots commented Feb 11, 2018

    #outside of def
    #when image is smaller than 10kb(image_path is recognized as a string by twitter)monkey patch
     module Twitter::Image
       def self.open_from_url(image_path)
         image_file = open(image_path)
         return image_file unless image_file.is_a?(StringIO)
         file_name = File.basename(image_path)
        temp_file = Tempfile.new(file_name)
        temp_file.binmode
        temp_file.write(image_file.read)
        temp_file.close
        open(temp_file.path)
      end
    end

    @social_product.images.first(4).each do |image|
    File.write "twitter#{@twitter_counter}.png", open(image.src).read
        @twitter_images << "./twitter#{@twitter_counter}.png"
        @twitter_counter = @twitter_counter + 1
    end
    @twitter_images = @twitter_images.map { |filename| File.new(filename) }
    begin
        @twitter_info = @twitter.update_with_media(@twitter_post, @twitter_images)
    rescue
        @twitter_images = Twitter::Image.open_from_url(@twitter_images)
        @twitter_info = @twitter.update_with_media(@twitter_post, @twitter_images)
    end
@astrolince

This comment has been minimized.

Copy link

@astrolince astrolince commented Feb 12, 2018

When this gonna be merged?

@sferik sferik closed this in 556d689 Jun 11, 2018
@obiwankennedy

This comment has been minimized.

Copy link

@obiwankennedy obiwankennedy commented Sep 4, 2018

No release have been made with this fix ? The version 6.2.0 still has this bug.

@NilLau

This comment has been minimized.

Copy link

@NilLau NilLau commented Nov 28, 2018

In my case, replacing .rvm/gems/ruby-2.5.1/gems/twitter-6.2.0/lib/twitter/rest/request.rb to request.rb fixes the problem.

@mitchellkrogza

This comment has been minimized.

Copy link

@mitchellkrogza mitchellkrogza commented Feb 12, 2019

Thank you @ssrzz that fixed it for me too 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.