Coder Social home page Coder Social logo

Comments (5)

clayallsopp avatar clayallsopp commented on September 24, 2024

Use:

AFMotion::Image.get("https://www.google.com/images/srpr/logo11w.png") do |result|
  puts result.object # UIImage
end

from afmotion.

cyberfox avatar cyberfox commented on September 24, 2024

My understanding is that this does not retrieve the actual bits, it retrieves an NSImage object. Am I wrong?

from afmotion.

clayallsopp avatar clayallsopp commented on September 24, 2024

You can use the UIImage object to extract that information, no?

imageData = UIImagePNGRepresentation(image) # NSData instance

from afmotion.

cyberfox avatar cyberfox commented on September 24, 2024

While I was not aware of that, it still has a problem that I'm recompressing the image that came from the remote side, and doesn't address the core issue. (I'm sorry I used an image as the example here, it confused the problem.)

My core issue is that the AFMotion::HTTP.get method apparently expects HTML, when it shouldn't force any particular content-type. If I want to use it to retrieve an application/dmg it should work.

Here's the headers that it sends (with the 2.1.4 version):

GET / HTTP/1.1
Host: localhost:9090
Accept: */*
Accept-Language: en;q=1, ja;q=0.9, fr;q=0.8, de;q=0.7, es;q=0.6, it;q=0.5
Connection: keep-alive
Accept-Encoding: gzip, deflate
User-Agent: MyApplication/1.0 (Mac OS X Version 10.9.2 (Build 13C64))

Given that it says it accepts */*, I think that the content type shouldn't fail on return. Is there an easy workaround to force AFMotion::HTTP.get to actually retrieve an arbitrary content-type, potentially returning it as NSData or something similar?

from afmotion.

cyberfox avatar cyberfox commented on September 24, 2024

Ah! I understand now; your other fix 12caa46 apparently fixed this! I can now access request.object as follows:

AFMotion::HTTP.get("https://www.google.com/images/srpr/logo11w.png") {|result| p result.object }

Thanks muchly!

from afmotion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.