Skip to content

Conversation

@CarlSchwan
Copy link
Member

@CarlSchwan CarlSchwan commented Aug 15, 2025

Summary

This is faster than going back to nextcloud and setting up the file system to download the files.

TODO

  • Currently in my dev docker setup, the minio service is not available from outside, so the url can't be accessed. There should be a way to configure whether the s3 service is available or not from outside Minio + pre-signed urls juliusknorr/nextcloud-docker-dev#431
  • Also expose the preview url like this (let's move that to a seperate PR)

Checklist

@CarlSchwan CarlSchwan self-assigned this Aug 15, 2025
@invario
Copy link
Contributor

invario commented Aug 17, 2025

FYI I've been working on #53634 to enable previews to generate by passing a presigned URL to ffmpeg.

@ldpr
Copy link

ldpr commented Oct 18, 2025

very excited for this! it'll be a gamechanger for nextcloud users no longer being "choked" behind nextcloud proxying everything. can't wait!
thanks so much @CarlSchwan !!

@ser
Copy link

ser commented Oct 22, 2025

I am also super excited, as it would allow to distribute data geographically with several auto mirroring minio instances across continents. Web browsers are automatically getting the file from the shortest round trip servers.

@artonge artonge linked an issue Oct 29, 2025 that may be closed by this pull request
@volf3n
Copy link

volf3n commented Nov 5, 2025

Oh, this would be amazing for something I've been cooking up on the side!
Any idea how the development is going?

@CarlSchwan CarlSchwan added 3. to review Waiting for reviews pending documentation This pull request needs an associated documentation update and removed 2. developing Work in progress labels Nov 10, 2025
@CarlSchwan CarlSchwan marked this pull request as ready for review November 10, 2025 14:41
@CarlSchwan CarlSchwan requested a review from a team as a code owner November 10, 2025 14:41
@CarlSchwan CarlSchwan requested review from Altahrim, come-nc, icewind1991 and salmart-dev and removed request for a team November 10, 2025 14:41
Comment on lines 309 to 314
* @return array|false
* @param string $path Either the path or the fileId
* @return array{url: ?string}|false
* @since 9.0.0
*/
public function getDirectDownload(string $path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still being called with path anywhere? implementations having to support both is kinda awkward (and an issue in the (rare) case of a numeric filename in the root of the storage).

I would either just drop the path option from this method or create a new method (in an extension trait) for getDirectDownloadById.

Also, the return type array should mention expiration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a getDirectDownloadById API and deprecated getDirectDownload as it is not really used anymore.

}

try {
return (string)$this->getConnection()->createPresignedRequest($command, $expiration, [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to make sure, have we confirmed that creating presigned urls is cheap enough to do for every file in a directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked with blackfire, creating a pre-signed urls has a minimal impact on performance since it's only doing an hash.

The only thing expensive is creating the connection object, because we are doing a HEAD request to the s3 server all the time, which I am fixing here: https://github.com/nextcloud/server/pull/56395/files

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to comment that efficiency is not the only important parameter, as there are cases where the nextcloud server itself is unable to serve files because of the company policies which are forcing S3 servers to face the customer instead

@lakema17
Copy link

Is there any way we can get a basic guide to testing this PR? I'm looking to get some basic performance data so I can plan my setup ahead of the release (and also have a bit of fun with it)

@CarlSchwan CarlSchwan force-pushed the s3-signed-url branch 2 times, most recently from 09235cc to fd292e4 Compare November 12, 2025 14:55
@CarlSchwan
Copy link
Member Author

Is there any way we can get a basic guide to testing this PR? I'm looking to get some basic performance data so I can plan my setup ahead of the release (and also have a bit of fun with it)

Best way is to test this PR is with juliusknorr/nextcloud-docker-dev#431 just change in .env PRIMARY to minio and start it up with docker compose up minio nextcloud

@CarlSchwan CarlSchwan force-pushed the s3-signed-url branch 3 times, most recently from a9ac87c to 9fa3576 Compare November 19, 2025 11:58
Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. How is this behaving for files without read or download permissions?
  2. What happens if the object store is not available publicly?

@CarlSchwan CarlSchwan force-pushed the s3-signed-url branch 2 times, most recently from 93cca86 to e903621 Compare November 19, 2025 13:56
@CarlSchwan
Copy link
Member Author

  • How is this behaving for files without read or download permissions?

I added a check for read. For the download permissions, the downloadUrl dav properties is already completely disabled for shares.

  • What happens if the object store is not available publicly?

This is opt-in an behavior. You need to mark 'use_presigned_url' to true in your config.php for the object store. I need to add it to the documentation

This is faster than going back to nextcloud to download the files.

This is an opt-in setting that can be enabled by setting
use_presigned_url in the object store config.

Additionally add support for the proxy config which is needed in a
docker setup. See juliusknorr/nextcloud-docker-dev#431

Signed-off-by: Carl Schwan <[email protected]>
@artonge
Copy link
Contributor

artonge commented Nov 19, 2025

This is opt-in an behavior. You need to mark 'use_presigned_url' to true in your config.php for the object store. I need to add it to the documentation

Should we add a setup check to hint to this new possibility?

Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as is.

@ser
Copy link

ser commented Nov 19, 2025

  • What happens if the object store is not available publicly?

This is opt-in an behavior. You need to mark 'use_presigned_url' to true in your config.php for the object store. I need to add it to the documentation

I would propose to specify the URL instead, as the URL of the front S3 server might be and often is different than the one set internally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement pending documentation This pull request needs an associated documentation update performance 🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve thumbnail reading performance with more direct access