Go to file
2017-07-04 17:34:37 +02:00
lib Actually #url needs to deal with the disposition 2017-07-04 17:34:37 +02:00
test Actually #url needs to deal with the disposition 2017-07-04 17:34:37 +02:00
.gitignore Ignore byebug history 2017-07-01 12:09:54 +02:00
activefile.gemspec Switch to double quotes for Rails linter 2017-07-01 12:05:32 +02:00
Gemfile Use lazy-loaded factory method for site configuration 2017-07-04 16:44:50 +02:00
Gemfile.lock Add a Google Cloud Storage site 2017-07-03 17:54:57 -04:00
MIT-LICENSE First sketching 2017-06-30 19:12:58 +02:00
Rakefile Extract shared tests 2017-07-04 15:28:47 +02:00
README.md Fix reference 2017-07-03 16:04:14 +02:00

Active File

...

Example

class Person < ApplicationRecord
  has_one :avatar
end

class Avatar < ApplicationRecord
  belongs_to :person
  belongs_to :image, class_name: 'ActiveFile::Blob'

  has_file :image
end

avatar.image.url(expires_in: 5.minutes)


class ActiveFile::DownloadsController < ActionController::Base
  def show
    head :ok, ActiveFile::Blob.locate(params[:id]).download_headers
  end
end


class AvatarsController < ApplicationController
  def create
    # @avatar = Avatar.create \
    #   image: ActiveFile::Blob.save!(file_name: params.require(:name), content_type: request.content_type, data: request.body)
    @avatar = Avatar.create! image: Avatar.image.extract_from(request)
  end
end


class ProfilesController < ApplicationController
  def update
    @person.update! avatar: @person.avatar.update!(image: )
  end
end

License

Active File is released under the MIT License.