Skip to content

Instantly share code, notes, and snippets.

View GodsEye-07's full-sized avatar
👨‍💻
Digitalising the world with CODE

Ayush Verma GodsEye-07

👨‍💻
Digitalising the world with CODE
View GitHub Profile
@GodsEye-07
GodsEye-07 / AWSS3TransferManager.swift
Last active February 4, 2020 12:46
AWSS3TransferManager
let bucketName = "***** your bucket name *****"
func uploadFile(with resource: String, type: String) { //1
let key = "\(resource).\(type)"
let localImagePath = Bundle.main.path(forResource: resource, ofType: type)! //2
let localImageUrl = URL(fileURLWithPath: localImagePath)
let request = AWSS3TransferManagerUploadRequest()!
request.bucket = bucketName //3
request.key = key //4
@GodsEye-07
GodsEye-07 / AppDelegate.swift
Last active February 4, 2020 13:08
S3 Credentials
func initializeS3() {
let poolId = "***** your poolId *****"
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: .APSouth1, //other regionType according to your location.
identityPoolId: poolId
)
let configuration = AWSServiceConfiguration(region: .APSouth1, credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
}
@GodsEye-07
GodsEye-07 / AWSS3TransferUtility.swift
Last active February 4, 2020 12:48
AWSS3TransferUtility
let bucketName = "***** your bucket name *****"
var completionHandler: AWSS3TransferUtilityUploadCompletionHandlerBlock?
func uploadVideo(with resource: String,type: String){ //1
let key = "\(resource).\(key)"
let resource = Bundle.main.path(forResource: resource, ofType: type)!
let Url = URL(fileURLWithPath: resource)
let expression = AWSS3TransferUtilityUploadExpression()
@GodsEye-07
GodsEye-07 / info.xml
Created February 5, 2020 10:02
Internet permission for AWS S3 upload
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>