nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.4k stars 4.07k forks source link

Add support to custom user uploads dir #38505

Open tanganellilore opened 1 year ago

tanganellilore commented 1 year ago

Is your feature request related to a problem? Please describe. Hi Team, I notice that actually is not possible customize the path where temporary uploads ,<user_id>/uploads, are stored. This happen for example with Chunk file.

It's possible customize the temp path for PHP and so on, but ufter tmp path, chunks go into <user_id>/uploads and then, after assebling, will go to the standar data folder for user.

It will be cool, have a settings that will allow us to "link" <user_id>/uploads to specific path, where we can mount, for example, local storage, that in general is much faster than long term storage.

Describe the solution you'd like Add a option to customize <user_id>/uploads or adding a symlink to it.

Describe alternatives you've considered Actually there is no alternative apart disable chunking.

Additional context I will send you a PR that will address this feature with usage of symlink and adding of new config parameter called uploadsdirectory. More info in the PR.

Thanks

come-nc commented 1 year ago

I’m not sure I understand the problem, when assembling the chunks the data will move to the datafolder anyway, no?

You say "Actually there is no alternative apart disable chunking.", but how disabling chunking is improving your situation, the data goes to the same place?

tanganellilore commented 1 year ago

Try to think in a situation where you want to store temporary file (php tmp file ad chunks) to a local and fast storage. Then assembling can read from this storage and put in a datafodler, mounted in a different storage.

Actually the flow, with chunk enable is this one (for my understanding):

  1. Upload from UI and PUT chunks
  2. PHP store it in tmp folder
  3. Move it in <user_id>/uploads/web-xxxxx folder, with chunk id (like 1,2,3 etc...)
  4. At the end of all chunks, Assembling will read all chunks and write to datafolder file.

So if we are in a situation similar to tmp PHP config, where you want to store chunks in a different disk than datafolder disk, it's not possible.

My PR try to address is, with creation of symlink, in that way we can mout a specific path with speficif disk, and avoid to overlad datafolder disk with all this I/O from point 2-3 and part of point 4

come-nc commented 1 year ago

Yes but why? What benefits brings storing chunks somewhere else than datafolder, since the data is copied there in the end anyway?

And why would disabling chunking be a workaround as you suggested?

tanganellilore commented 1 year ago

Disabling chunk it's not a "workaroud" but a simple bypass problem, that move it in a different discussion (as described on the doc related tmp php size that need to be sufficient large for user uploads). Disabling it you can simply store all file in tmp (php allocate it) and then move to datafolder, but is not a workaround.

Related to benefits, image to have a datafolder stored on slow disk (like sata disk), actually you read/write to that disk 3 time:

  1. to write chunk
  2. to read chunk for assembling
  3. to write assembled file

With usage of different path, for example usage of fast disk for PHP tmp and chunk folder (like nvme or ssd), we can reduce the usage of slow disk only to assembling (point 3).

In a local enviroment or very small env, this will not save a lot of time, but in a large scale enviroment, store chunks in a "dedicated" disk that not use I/O of datafolder disk (like tmp of php) it will be much perfomant.