Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

create image from base64 ruby

start_regex = /data:image/[a-z]{3,4};base64,/
filename ||= SecureRandom.hex

regex_result = start_regex.match(base64_data)
if base64_data && regex_result
  start = regex_result.to_s
  tempfile = Tempfile.new(filename)
  tempfile.binmode
  tempfile.write(Base64.decode64(base64_data[start.length..-1]))
end
Comment

PREVIOUS NEXT
Code Example
Ruby :: ERROR: While executing gem ... (Gem::FilePermissionError) 
Ruby :: ruby array group by attribute 
Ruby :: ruby uuid 
Ruby :: ruby variable in string 
Ruby :: ruby get current datetime 
Ruby :: check current route rails 
Ruby :: rails prepare testing db 
Ruby :: rails generate migration array default value 
Ruby :: How can I rename a database column in a Ruby on Rails migration? 
Ruby :: rails migration change type of column 
Ruby :: rails video_tag with <source 
Ruby :: rails difference in minutes between 2 datetime 
Ruby :: rails remove foreign key 
Ruby :: get date millis rails 
Ruby :: ruby ||= 
Ruby :: autoload lib directory rails 
Ruby :: print in ruby 
Ruby :: ruby array unshift 
Ruby :: rails logger info 
Ruby :: how to add to array ruby 
Ruby :: params except rails 
Ruby :: ruby while loop 
Ruby :: ruby get instance variables without accessor 
Ruby :: rails migration remove column 
Ruby :: ruby %w 
Ruby :: force stop rails server 
Ruby :: rails active storage get all attachment names 
Ruby :: How to handle permission in rails 
Ruby :: ruby negative indices fizz buzz 
Ruby :: rails spreadsheet email attachment 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =