S
S
Sahnen2016-04-24 13:47:05
JavaScript
Sahnen, 2016-04-24 13:47:05

Uploading photos to the server - how to do it right?

For some reason, I decided to abandon CarrierWave and make my own crutch. The situation is as follows: you need to upload photos to an album that is stored in the cloud. The album for each photo contains the original and resized thumbnails for different previews. I see 2 options:
1) Do it all in the browser and upload directly to the cloud.
Plus: the entire load is removed from the server. The server gets only links to finished images in the cloud.
Minus: in the cloud, you need to go through authorization using a GET request, so you have to store access data in a js script, i.e. open to any user.
2) Upload the image first to the server, then, using, for example, rmagick, make resized copies and upload these copies to the cloud from the server.
Plus: all logins and passwords are hidden from a curious user.
Minus: load on the server + traffic.
I will assume that in the first case it is possible to prohibit cross-domain requests in the cloud and, it seems, you can not hide access data. There are no thoughts on the second option.
How, after all, is it more correct to do it, or maybe there are more elegant solutions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shilka, 2016-04-24
@glitch536

In my opinion, there is no such thing as "correct", there is only a task that is performed or not. However, I will allow myself a few tips based on the description
1. Security is more important than performance. Storing passwords in plain text on the client is a bad idea. If we consider uploading to the cloud, then to the user's cloud, then providing access to files to your application
2. If you are sure that performance will be a bottleneck, you can consider slicing on the client (the code will become more complicated due to the need to support different browsers). The problem can also be solved by buying a stronger iron.
In general, I use the following strategy: to start with, implement the simplest option and optimize if necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question