{"id":19777970,"url":"https://github.com/shrinerb/shrine-fog","last_synced_at":"2025-04-30T20:30:29.877Z","repository":{"id":56895447,"uuid":"47467406","full_name":"shrinerb/shrine-fog","owner":"shrinerb","description":"Fog storage for Shrine","archived":false,"fork":false,"pushed_at":"2020-05-06T10:44:59.000Z","size":38,"stargazers_count":11,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-21T21:23:37.730Z","etag":null,"topics":["cloud-storage","fog","shrine","storage"],"latest_commit_sha":null,"homepage":"http://fog.io/","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/shrinerb.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":"2015-12-05T18:23:19.000Z","updated_at":"2020-05-15T13:43:38.000Z","dependencies_parsed_at":"2022-08-21T01:20:48.444Z","dependency_job_id":null,"html_url":"https://github.com/shrinerb/shrine-fog","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-fog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-fog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-fog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-fog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shrinerb","download_url":"https://codeload.github.com/shrinerb/shrine-fog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251740652,"owners_count":21636096,"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":["cloud-storage","fog","shrine","storage"],"created_at":"2024-11-12T05:27:16.309Z","updated_at":"2025-04-30T20:30:29.858Z","avatar_url":"https://github.com/shrinerb.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shrine::Storage::Fog\n\nProvides [Fog] storage for [Shrine].\n\nFog is an abstraction over a variety of cloud storages (e.g. Google Cloud and\nDropbox).\n\n## Installation\n\n```ruby\ngem \"shrine-fog\", \"~\u003e 2.0\"\ngem \"fog-xyz\" # Fog gem for the storage you want to use\n```\n\n## Usage\n\nRequire the appropriate Fog gem, and assign the parameters for initializing\nthe storage:\n\n```rb\nrequire \"shrine/storage/fog\"\nrequire \"fog/google\"\n\nShrine.storages[:store] = Shrine::Storage::Fog.new(\n  provider: \"Google\",                                    #\n  google_storage_access_key_id: \"ACCESS_KEY_ID\",         # Fog credentials\n  google_storage_secret_access_key: \"SECRET_ACCESS_KEY\", #\n  directory: \"uploads\",\n)\n```\n\nYou can also assign a Fog storage object as the `:connection`:\n\n```rb\nrequire \"shrine/storage/fog\"\nrequire \"fog/google\"\n\ngoogle = Fog::Storage.new(\n  provider: \"Google\",\n  google_storage_access_key_id: \"ACCESS_KEY_ID\",\n  google_storage_secret_access_key: \"SECRET_ACCESS_KEY\",\n)\n\nShrine.storages[:store] = Shrine::Storage::Fog.new(\n  connection: google,\n  directory: \"uploads\",\n)\n```\n\nIf both cache and store are a Fog storage, the uploaded file is copied to store\ninstead of reuploaded.\n\n### URLs\n\nBy default shrine-fog will generate signed expiring URLs.\n\n```rb\nuploaded_file.url(\"image.jpg\") #=\u003e \"https://my-bucket.s3-eu-west-1.amazonaws.com/foo?X-Amz-Expires=3600\u0026X-Amz-Date=20151217T102105Z\u0026X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIAIJF55TMZZY45UT6Q/20151217/eu-west-1/s3/aws4_request\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=6908d8cd85ce4469f141a36955611f26d29ae7919eb8a6cba28f9194a92d96c3\"\n```\n\nYou can modify the URL expiration date via `:expires` (the default is `3600`):\n\n```rb\nuploaded_file.url(\"image.jpg\", expires: 90) #=\u003e \"https://my-bucket.s3-eu-west-1.amazonaws.com/foo?X-Amz-Expires=90\u0026X-Amz-Date=20151217T102105Z\u0026X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIAIJF55TMZZY45UT6Q/20151217/eu-west-1/s3/aws4_request\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=6908d8cd85ce4469f141a36955611f26d29ae7919eb8a6cba28f9194a92d96c3\"\n```\n\nIf the files you're uploading are public readable (e.g. you're passing the\ncorrect ACL on upload, `acl: \"publicRead\"` for fog-google), and you want to\ngenerate public URLs, you can pass `public: true` to `#url`:\n\n```rb\nuploaded_file.url(\"image.jpg\", public: true) #=\u003e \"https://my-bucket.s3-eu-west-1.amazonaws.com/image.jpg\"\n```\n\nAny additional URL options will be forwarded directly to the provider's\n`File#url` method.\n\nYou can use the `default_url_options` Shrine plugin to set default URL options.\n\n### Upload options\n\nDynamic upload options can be passed via the `upload_options` plugin:\n\n```rb\nShrine.plugin :upload_options, store: { acl: \"publicRead\" }\n```\n\nYou can also specify default upload options on storage initialization:\n\n```rb\nShrine::Storage::Fog.new(upload_options: { acl: \"publicRead\" }, **options)\n```\n\n### S3 or Filesystem\n\nIf you want to store your files to Amazon S3 or the filesystem, you should use\nthe storages that ship with Shrine (instead of [fog-aws] or [fog-local]) as\nthey are much more advanced.\n\n## Running tests\n\nTests use [fog-aws], so you'll have to create an `.env` file with appropriate\ncredentials:\n\n```sh\n# .env\nS3_ACCESS_KEY_ID=\"...\"\nS3_SECRET_ACCESS_KEY=\"...\"\nS3_REGION=\"...\"\nS3_BUCKET=\"...\"\n```\n\nAfterwards you can run the tests:\n\n```sh\n$ bundle exec rake test\n```\n\n## Inspiration\n\nThis gem was inspired by [refile-fog].\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n\n[Fog]: http://fog.io/\n[Shrine]: https://github.com/shrinerb/shrine\n[fog-aws]: https://github.com/fog/fog-aws\n[fog-local]: https://github.com/fog/fog-local\n[refile-fog]: https://github.com/refile/refile-fog\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshrinerb%2Fshrine-fog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshrinerb%2Fshrine-fog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshrinerb%2Fshrine-fog/lists"}