How long does a downloadURL of an asset persist?

https://developer.apple.com/documentation/cloudkitjs/cloudkit/database/1628735-saverecords mentions that we can use the downloadURL to provide a link to the user, however it seems this URL will expire after some time, and it will return 410 GONE as http status code when it expires.

How long does the link persist before it expires, is it documented anywhere?

Accepted Reply

Thanks for your question.

downloadURL lasts for about an hour. If you want to know the exact expiration of the URL, you can look at the e= query parameter in the downloadURL itself. It's a UNIX epoch date in seconds. So in JavaScript, you could see the human readable date by creating a Date object with that numeric value. For example, const exp = new Date(TheEValue). However, this is an implementation detail that you cannot rely on and I would not suggest you take that approach.

There is no way to adjust the time-to-live of the URL. If you want something longer lasting, you'll have to provide a solution yourself. If you'd prefer not to do that, then you'll have to gracefully handle any errors as a result of accessing that URL.

  • Related to the assets, what hashing algorithm is used to produce the fileChecksum? "The signature of a file returned from the file upload step. This key is required for the public and private database." AssetDictionary. FB9826224

  • Thanks! this is super useful!

Add a Comment

Replies

Thanks for your question.

downloadURL lasts for about an hour. If you want to know the exact expiration of the URL, you can look at the e= query parameter in the downloadURL itself. It's a UNIX epoch date in seconds. So in JavaScript, you could see the human readable date by creating a Date object with that numeric value. For example, const exp = new Date(TheEValue). However, this is an implementation detail that you cannot rely on and I would not suggest you take that approach.

There is no way to adjust the time-to-live of the URL. If you want something longer lasting, you'll have to provide a solution yourself. If you'd prefer not to do that, then you'll have to gracefully handle any errors as a result of accessing that URL.

  • Related to the assets, what hashing algorithm is used to produce the fileChecksum? "The signature of a file returned from the file upload step. This key is required for the public and private database." AssetDictionary. FB9826224

  • Thanks! this is super useful!

Add a Comment