Skip to content

Instantly share code, notes, and snippets.

View jcjimenez's full-sized avatar

JC Jimenez jcjimenez

View GitHub Profile
@jcjimenez
jcjimenez / CredentialsProxy.swift
Last active May 22, 2023 14:44
Amplify v2 to AWS SDK iOS Credentials Provider
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
import AWSCognitoAuthPlugin
import AWSCore
import AWSPluginsCore
@jcjimenez
jcjimenez / AmplifyConfig.swift
Last active March 9, 2023 21:11
Convenience struct for extracting Amplify configuration from an application's bundle.
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
/// Convenience struct for extracting Amplify configuration from an application's bundle.
///
/// Usage example:
@jcjimenez
jcjimenez / PresignedUrlGenerator.swift
Created March 9, 2023 20:31
Convenience class used to generate pre-signed URLs in the same way as Amplify's AWSS3StoragePlugin.
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
import AWSPluginsCore
import AWSS3
import AWSS3StoragePlugin
import ClientRuntime
import Foundation
/// FoundationHttpClientEngine conforming to
/// [HttpClientEngine](x-source-tag://HttpClientEngine)
extension FoundationHttpClientEngine: HttpClientEngine {
func execute(request: ClientRuntime.SdkHttpRequest) async throws -> ClientRuntime.HttpResponse {
let urlRequest = try self.request(for: request)
let (data, response) = try await URLSession.shared.upload(for: urlRequest, from: urlRequest.httpBody ?? Data())
guard let http = response as? HTTPURLResponse else {