canpan14
canpan14

Reputation: 1273

PUT Presigned URL expires before download of file completes

Bit of an odd case where my API is sent a presigned URL to write to, and a presigned URL to download the file from.

The problem is that if they send a very large file, the presigned url we need to write to can expire before it gets to that step (some processing happens in between the read/write).

Is it possible to 'open' the connection for writing early to make sure it doesn't expire, and then start writing once the earlier process is done? Or maybe there is a better way of handling this.

The order goes:

  1. Receive API request with a downloadUrl and an uploadUrl
  2. Download the file
  3. Process the file
  4. Upload the file to the uploadUrl

TL;DR: How can I ensure the url for #4 doesn't expire before I get to it?

Upvotes: 0

Views: 189

Answers (1)

smac2020
smac2020

Reputation: 10704

When generating the pre-signed URL, you have complete control over the time duration. For example, this Java code shows how to set the time when creating a GetObjectPresignRequest object:

 GetObjectPresignRequest getObjectPresignRequest =  GetObjectPresignRequest.builder()
                            .signatureDuration(Duration.ofMinutes(10))
                            .getObjectRequest(getObjectRequest)
                            .build();

So you can increase the time limit in such situations.

Upvotes: 1

Related Questions