« Mechanize for page scraping facebook.Odd mysql error »

7 comments

  1. § Luis Lavena Email said on :
    The main issue you show here is related to the way files are being handled under Windows.

    By default Ruby open files in text mode ('w'), that works under POSIX but under Windows, you need the binary 'b' for the mode or call #binmode as you did.

    There are several patches for Tempfile under Windows, some of those came from Rails, try googling for that if you need more info.
  2. § Brian® Email said on :
    If you check a couple posts back, I talked about windows and binary mode. I have patched my Tempfile to do that by default already.

    The part here that is confusing me is why I should need to do a rewind on the StringIO before reading it. That and the fact that you have to deal with uploads in 2 ways depending on the file size.
  3. § Alien Email said on :
    Hi, what about saving files to the database?
    I always get a weird error trying that...
  4. § Brian® Email said on :
    While I have never done that, migrations have a field call 'binary' which would probably do the trick

    In the migration:

    t.column :myFile, :binary

    To save it, you would do something along the lines of:

    myObject.myFile = @realFile.read
  5. § Alien Email said on :
    Thanks for the answer, that was just what i made, but when i did the object.save, mysql report an error, and WEBrick crashes, something weird happens...
  6. § Brian® Email said on :
    Send me an email with your error messages and logs, I might be able to help you figure it out:

    brian@briansblog.net
  7. § sack Email said on :
    you should append the following line to the end of the solution:
    tempfile.rewind

This post has 1 feedback awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
Originaly designed and iconized by N.Design Studio. Ported to b2evolution by Tender Feelings