{"id":21301720,"url":"https://github.com/funbox/shrine-webdav","last_synced_at":"2025-07-11T20:31:18.543Z","repository":{"id":49117492,"uuid":"92935786","full_name":"funbox/shrine-webdav","owner":"funbox","description":"Provides a simple WebDAV storage for Shrine","archived":false,"fork":false,"pushed_at":"2021-10-19T06:44:29.000Z","size":40,"stargazers_count":17,"open_issues_count":0,"forks_count":7,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-06T08:35:34.785Z","etag":null,"topics":["shrine","webdav","webdav-storage"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-31T10:41:19.000Z","updated_at":"2022-02-26T01:24:39.000Z","dependencies_parsed_at":"2022-09-24T02:50:55.836Z","dependency_job_id":null,"html_url":"https://github.com/funbox/shrine-webdav","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/funbox/shrine-webdav","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fshrine-webdav","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fshrine-webdav/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fshrine-webdav/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fshrine-webdav/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funbox","download_url":"https://codeload.github.com/funbox/shrine-webdav/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fshrine-webdav/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264892162,"owners_count":23679245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["shrine","webdav","webdav-storage"],"created_at":"2024-11-21T15:50:32.394Z","updated_at":"2025-07-11T20:31:13.528Z","avatar_url":"https://github.com/funbox.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shrine::Storage::WebDAV\n\n[![Build Status](https://travis-ci.org/funbox/shrine-webdav.svg?branch=master)](https://travis-ci.org/funbox/shrine-webdav)\n\nProvides a simple WebDAV storage for [Shrine](https://shrinerb.com/).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'shrine-webdav'\n```\n\n## Usage\n\nSuppose you have Report model which should be able to store data in a remote WebDAV storage.\n\n```ruby\nclass Report \u003c ApplicationRecord\nend\n# == Schema Information\n#\n# Table name: reports\n#\n#  id                :uuid             not null, primary key\n#  name              :string           not null\n#  created_at        :datetime         not null\n#  updated_at        :datetime         not null\n```\n\nBefore you start add attributes pointing to remote files to your model you should describe Uploader class:\n\n```ruby\n# app/models/reports/report_uploader.rb\nclass ReportUploader \u003c Shrine\n  plugin :activerecord\n  plugin :logging, logger: Rails.logger\n\n  def generate_location(_io, context)\n    uuid = context[:record].id\n    \"#{uuid}.#{context[:name]}\"\n  end\nend\n```\n\nYou don't have to override method `generate_location`, but if you didn't you would have random file names.\n\nNow you can add the attributes:\n\n```ruby\nclass Report \u003c ApplicationRecord\n  include ReportUploader::Attachment.new(:pdf)\n  include ReportUploader::Attachment.new(:xls)\nend\n```\n\nNote corresponding migrations:\n\n```ruby\nclass AddFileAttributes \u003c ActiveRecord::Migration[5.1]\n  def change\n    add_column :reports, :xls_data, :text\n    add_column :reports, :pdf_data, :text\n  end\nend\n```\n\nCreate file `shrine.rb` in `config/initializers/` to configure WebDAV storage:\n\n```ruby\n# config/initializers/shrine.rb\nrequire 'shrine'\nrequire \"shrine/storage/webdav\"\n\nShrine.storages = {\n  cache: Shrine::Storage::WebDAV.new(host: 'http://webdav-server.com', prefix: 'your_project/cache'),\n  store: Shrine::Storage::WebDAV.new(host: 'http://webdav-server.com', prefix: 'your_project/store')\n}\n```\n\nNow you can use your virtual attributes `pdf` and `xls` like this:\n\n```ruby\nreport = Report.new(name: 'Senseless report')\n\n# here you are going to have file sample.pdf uploaded\n# to \"http://webdav-server.com/your_project/cache/#{report.id}.pdf\"\nreport.pdf = File.open('sample.pdf')\n\n# file sample.xls is being uploading\n# to \"http://webdav-server.com/your_project/cache/#{report.id}.xls\"\nreport.xls = File.open('sample.xls')\n\n# after committing in database both files sample.pdf and sample.xls have\n# been uploaded to \"http://webdav-server.com/your_project/store/...\"\nreport.save\n```\n\nGem also supports http options `timeout` and `basic auth` Basic usage:\n\n```\nShrine::Storage::WebDAV.new(\n  host: 'http://webdav-server.com',\n  prefix: 'your_project/store',\n  http_options: {\n    basic_auth: { user: 'user', pass: 'pass' },\n    timeout: { connect: 5, write: 2, read: 10 }\n  }\n)\n```\n\nYou can also use global timeouts like this:\n\n```\nShrine::Storage::WebDAV.new(\n  host: 'http://webdav-server.com',\n  prefix: 'your_project/store',\n  http_options: {\n    timeout: 3\n  }\n)\n```\n\n## Development\n\nAfter checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\nTo release a new version, update the version number in `shrine-webdav.gemspec`, and then run `bundle exec rake release`,\nwhich will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/funbox/shrine-webdav. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fshrine-webdav","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunbox%2Fshrine-webdav","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fshrine-webdav/lists"}