From ce75ec17a624a1c1dfd29ffd29dd4b99e03860e3 Mon Sep 17 00:00:00 2001 From: Neil Raina Date: Fri, 31 Jan 2025 15:04:47 -0500 Subject: [PATCH] fix: ensure credentials in put This fixes a long standing issue where upload would return and expired token error even if the Credentials had more recent valid credentials. ### Root Cause The put method did not reset credentials in config. --- packages/storage/src/providers/AWSS3Provider.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/storage/src/providers/AWSS3Provider.ts b/packages/storage/src/providers/AWSS3Provider.ts index c745df0fa76..f27402c6210 100644 --- a/packages/storage/src/providers/AWSS3Provider.ts +++ b/packages/storage/src/providers/AWSS3Provider.ts @@ -599,6 +599,10 @@ export class AWSS3Provider implements StorageProvider { object: PutObjectInput['Body'], config?: T ): S3ProviderPutOutput { + const credentialsOK = await this._ensureCredentials(); + if (!credentialsOK || !this._isWithCredentials(this._config)) { + throw new Error(StorageErrorStrings.NO_CREDENTIALS); + } const opt = Object.assign({}, this._config, config); const { bucket, track, progressCallback, level, resumable } = opt; const {