New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

activestorage-sftp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

activestorage-sftp

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Gem Version

Remote DiskService through SFTP, for ActiveStorage.

Installation

Add this line to your application's Gemfile:

gem 'activestorage-sftp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activestorage-sftp

Usage

Each application server saves blobs to file server through SFTP:

# config/storage.yml
sftp:
  service: SFTP
  user: user
  root: /var/www/proj/shared/storage
  host: file.intranet
  public_host: https://file.internet
  password: <%= ENV['PASSWORD'] %> # optional

File server serves blobs using DiskService:

# config/storage.yml
local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

Or use it as backup for your primary service:

# config/storage.yml
mirrored:
  service: Mirror
  primary: local #/S3/AzureStorage/GCS
  mirrors:
    - sftp
sftp:
  service: SFTP
  user: user
  root: /etc/backup/proj
  host: secure.backup

Further configuration options:

use_public_url: Generate plain ("dumb") URLs of upload server

By default the generated URLs will include parameters for content_disposition, expiration hints etc. A generated blobs URL might thus look like:

https://publichost/PATH/rails/active_storage/disk/hash-hash/name.JPG?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D

If you prefer simple URLs like

https://publichost/PATH/hash

you can set a configuration option:

# config/storage.yml
sftp:
  simple_public_urls: true # defaults to false
verify_via_http_get: Faster existence verification via HTTP GET

The default way of verifying that a blob does exist is to login to the sftp server and stat() the relevant file. This is done e.g. before re-transforming and uploading an image variant. While other "caching" solutions exist to speed up that process, a simple and efficient way of verifying the existence of a file is to query the relevant server with an HTTP HEAD request. Depending on the setup this might not always be a viable way, so it can be switched on with a configuration option.

# config/storage.yml
sftp:
  verify_via_http_get: true # defaults to false

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/treenewbee/activestorage-sftp.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 23 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc