Skip to content

Commit 2638024

Browse files
committed
Rename file upload chapter
1 parent 6bb3c66 commit 2638024

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

Development practices/File upload.md renamed to Development practices/File uploads.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Our standard file upload setup includes:
2-
- using the Shrine gem
2+
- using Shrine gem
33
- direct S3 uploads
44
- [S3](https://aws.amazon.com/s3/) as file storage for production and staging servers, and disk storage for development.
55

66
# Shrine
77
There are several file upload gems out there. We use [Shrine](https://github.com/janko-m/shrine) because of its flexibility and maintainability.
8-
It is a general-purpose file uploader gem. Since it has no direct dependencies,
8+
It is a general-purpose file uploader gem. Since it has no direct dependency,
99
__it can be used in both Rails and non-Rails projects.__
1010

1111
Official docs can be found [here](https://shrinerb.com/)
@@ -16,7 +16,7 @@ Shrine features a rich plugin system which makes it incredibly easy to change it
1616

1717
Here are some of the plugins we use often:
1818
- [activerecord](https://shrinerb.com/docs/plugins/activerecord)
19-
- [backgrounding](https://shrinerb.com/docs/plugins/backgrounding)
19+
- [bakgrounding](https://shrinerb.com/docs/plugins/backgrounding)
2020
- [cached_attachment_data](https://shrinerb.com/docs/plugins/cached_attachment_data) - for forms
2121
- [derivatives](https://shrinerb.com/docs/plugins/derivatives)
2222
- [determine_mime_type](https://shrinerb.com/docs/plugins/determine_mime_type)
@@ -29,28 +29,23 @@ Here are some of the plugins we use often:
2929
## Security
3030
Files stored on S3 are private by default. This means file URLs will be signed and they will expire after some specified time.
3131

32-
It's best to explicitly set the expiration time for **each uploader class** using the [url_options](https://shrinerb.com/docs/plugins/url_options) plugin.
33-
34-
Some files need to be public, e.g. album covers. In that case, set the `acl` to `public-read` via the [upload_options](https://shrinerb.com/docs/plugins/upload_options) plugin for that uploader class.
35-
36-
## Processing images
37-
If you're uploading images, you should process them (file compression) and create **multiple versions** (derivatives in Shrine) of different sizes. Consult with frontend devs on required dimensions.
38-
39-
We use [image_processing gem](https://github.com/janko/image_processing) with the [libvips](https://libvips.github.io/libvips/), which is a better performant alternative to ImageMagick.
40-
41-
The **backgrounding** plugin should be combined with the processing for a better user experience.
32+
It's best to explicitly set the expiration time for **each uploader class** using [url_options](https://shrinerb.com/docs/plugins/url_options) plugin.
4233

34+
Some files need to be public, i.e. albums' covers. In that case, set the `acl` to `public-read` via [upload_options](https://shrinerb.com/docs/plugins/upload_options) plugin for that uploader class.
4335

4436
## Other guidelines
4537

46-
- Use the **jsonb** data type for file columns when possible.
38+
- Use **jsonb** data type for file columns when possible.
39+
40+
- If you're uploading images, you should process them (file compression) and create **multiple versions** (derivatives in Shrine) of different sizes. Consult with frontend devs on required dimensions.
41+
**Backgrounding** plugin should be combined with the processing for a better user experience.
4742

48-
- Always validate the **mime type** for uploaded files, as well as the extension if needed.
43+
- Always validate **mime type** for uploaded files, and extension if needed.
4944

5045
- Shrine doesn't automatically delete files from cache storage when moving them to store storage. Tell a DevOps to **set a lifecycle policy** with an appropriate amount of time **for cache storage** prefix.
5146

5247
# Direct S3 upload
53-
Mobile or web frontends often upload files through the app server, which means that the file does a double hop: from the frontend to the backend, then from the backend to the cloud storage service.
48+
Mobile or web front ends often upload files through the app server, which means that the file does a double hop: from the frontend to the backend, then from the backend to the cloud storage service.
5449

5550
Direct upload solves this double-hop performance problem by giving one-time credentials to the frontend app to upload files directly to the cloud, and it sends out references to those files to the backend.
5651

0 commit comments

Comments
 (0)