https://github.com/willnet/upload-file-with-security
https://github.com/willnet/upload-file-with-security
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/willnet/upload-file-with-security
- Owner: willnet
- Created: 2019-09-06T09:49:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T14:42:28.000Z (over 3 years ago)
- Last Synced: 2023-04-10T16:14:40.745Z (about 3 years ago)
- Language: Ruby
- Size: 1.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Upload file with security
shrineを使ったサンプルRailsアプリです
## セットアップ方法
mac前提
```
brew install libvips
./bin/setup
```
## 構成
- scaffoldでUserとSecretモデルを作っています
- それぞれ http://localhost:3000/users , http://localhost:3000/secrets でCRUDできます
- それぞれShrineでファイルアップロードできるようにしています
- Userは普通にon the flyでのファイル変換
- Secretもon the flyのファイル変換ですが、以下の点で異なります
- SecureDerivationsController#showでアクセス制限をする余地を作っています
- ファイルのパスにモデル名とIDを含めているので、そこから「アップロードしたファイルにアクセスする権限があるか否か」をチェック可能
- 要求された形式のファイルがストレージにない場合は、変換後ストレージに保存し次回はそれを使用する形式になっています
- CDNをつかわない前提