Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6319877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:52:41+00:00 2026-05-24T15:52:41+00:00

I want to save an image as a base64 string as part of a

  • 0

I want to save an image as a base64 string as part of a model in Rails.

Does anyone have advice for the migration file?
I assume that simply setting a type of String would not be suitable, given that the size of the string is often large e.g. > 2MB.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:52:41+00:00Added an answer on May 24, 2026 at 3:52 pm

    You could use either text or binary instead of string in your migration if you want to overcome the size limitation.

    http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column

    The API documentation gives this example:

    td.column(:picture, :binary, :limit => 2.megabytes)
    # => picture BLOB(2097152)
    

    The maximum size of TEXT or BLOB (binary) columns depends on your RDBMS (e.g. MySQL, PostgreSQL), available memory, and certain configuration settings. For instance, in MySQL, you should have a look at the max_allowed_packet option, which you can set to anything up to 1 GB.

    Regarding storage with Paperclip:

    Paperclip doesn’t allow database storage out of the box, so you have to write some custom code for that. Google gives me this:

    http://patshaughnessy.net/2009/5/29/paperclip-sample-app-part-3-saving-file-attachments-in-a-database-blob-column

    It’s outdated though, so I’m not sure if it’s helpful.

    More importantly:

    Note that storing files in database is generally not recommended which is why Paperclip doesn’t support it. Some reasons it’s a bad idea:

    1. When images are stored in DB, every image request requires a call to your Rails app and the database, which has a massive negative effect on performance. If you store images as files or on Amazon S3, your app will scale much better.

    2. Your database becomes large very quickly, which makes it harder to backup your data.

    3. Since different RDBMS have different rules for column size, column types, etc., migrating large columns to a different database (e.g. from MySQL to PostgreSQL) may involve difficulties.

    So I hope you have a good reason to do it anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an base64 picture string in coldfusion. How can I save this image
I have an image in an UIImageView and want to save it to the
I am trying to save an image from string. so I want to know
I have an image thumbnail, encoded as base64, that I want to use as
I have a method as shown below to save image as jpeg. I want
In my signed applet I have an Image object, Now I want to save
I want to save Image in Database with JSON web service .without image data
I'm using 3d in WPF and want to save it to a 2d image
I want to extract first frame of uploaded video and save it as image
I want to capture a single image from my webcam and save it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.