class Api::FilesController < Api::ApplicationController def create # file = params[:data] data_str = params[:data_str] file = File.new # file.data = data file.data_str = data_str end end class File < ActiveRecord::Base mount_uploader :data, FileDataUploader def data_str= v f = Tempfile.open "temp", encoding: 'ascii-8bit' f.write Base64.decode64(v) self.data = f end end ããã«è¯ãæ¹æ³ã¯ãã¡ã Rails 㧠Base64 ã¨
{{#tags}}- {{label}}
{{/tags}}