{"id":18839755,"url":"https://github.com/maximbilan/swift-amazon-s3-uploading-tutorial","last_synced_at":"2025-08-02T03:13:31.092Z","repository":{"id":76126229,"uuid":"76770439","full_name":"maximbilan/Swift-Amazon-S3-Uploading-Tutorial","owner":"maximbilan","description":"How to upload a file to Amazon S3 using Swift","archived":false,"fork":false,"pushed_at":"2018-09-22T10:22:01.000Z","size":717,"stargazers_count":77,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T06:55:14.145Z","etag":null,"topics":["amazon","amazon-s3-storage","amazon-s3-tutorial","ios","swift","tutorial","upload","upload-file"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximbilan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-18T08:01:54.000Z","updated_at":"2024-07-08T20:27:45.000Z","dependencies_parsed_at":"2023-02-25T05:30:38.012Z","dependency_job_id":null,"html_url":"https://github.com/maximbilan/Swift-Amazon-S3-Uploading-Tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maximbilan/Swift-Amazon-S3-Uploading-Tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FSwift-Amazon-S3-Uploading-Tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FSwift-Amazon-S3-Uploading-Tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FSwift-Amazon-S3-Uploading-Tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FSwift-Amazon-S3-Uploading-Tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximbilan","download_url":"https://codeload.github.com/maximbilan/Swift-Amazon-S3-Uploading-Tutorial/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FSwift-Amazon-S3-Uploading-Tutorial/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268330934,"owners_count":24233152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","amazon-s3-storage","amazon-s3-tutorial","ios","swift","tutorial","upload","upload-file"],"created_at":"2024-11-08T02:43:58.653Z","updated_at":"2025-08-02T03:13:31.059Z","avatar_url":"https://github.com/maximbilan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to upload a file to Amazon S3 using Swift\n\nI would like to share a simple tutorial how to upload a to \u003ca href=\"https://github.com/aws/aws-sdk-ios\"\u003eAmazon S3\u003c/a\u003e in \u003ci\u003eiOS\u003c/i\u003e using \u003ci\u003eSwift\u003c/i\u003e. Let’s go.\n\n![alt tag](https://raw.github.com/maximbilan/Swift-Amazon-S3-Uploading-Tutorial/master/img/img1.png)\n\nWe need to add \u003ca href=\"https://github.com/aws/aws-sdk-ios\"\u003eAmazon S3\u003c/a\u003e framework to your project.\u003cbr\u003e\nIn this example I will do this with helping \u003ca href=\"https://cocoapods.org\"\u003eCocoapods\u003c/a\u003e.\n\nCreate a \u003ci\u003ePodfile\u003c/i\u003e:\n\n\u003cpre\u003e\nplatform :ios, '8.0'\ninhibit_all_warnings!\nuse_frameworks!\ntarget 'AmazonS3Upload' do\npod 'AWSS3'\nend\n\u003c/pre\u003e\n\nRun the next command from \u003ci\u003eTerminal\u003c/i\u003e:\n\n\u003cpre\u003e\npod install\n\u003c/pre\u003e\n\nOpen the generated workspace. And after that we can implement uploading of files using frameworks from \u003ci\u003ePods\u003c/i\u003e.\n\nWe need to import 2 modules:\n\n\u003cpre\u003e\nimport AWSS3\nimport AWSCore\n\u003c/pre\u003e\n\nSet up a \u003ci\u003eAWS configuration\u003c/i\u003e  using your \u003ci\u003ecredentials\u003c/i\u003e. For example:\n\n\u003cpre\u003e\nlet accessKey = \"...\"\nlet secretKey = \"...\"\nlet credentialsProvider = AWSStaticCredentialsProvider(accessKey: accessKey, secretKey: secretKey)\nlet configuration = AWSServiceConfiguration(region: AWSRegionType.usEast1, credentialsProvider: credentialsProvider)\nAWSServiceManager.default().defaultServiceConfiguration = configuration\n\u003c/pre\u003e\n\nCreate an upload request:\n\n\u003cpre\u003e\nlet url = ...URL to your file...\nlet remoteName = \"Name of uploaded file\"\nlet S3BucketName = \"Name of your bucket on Amazon S3\"\nlet uploadRequest = AWSS3TransferManagerUploadRequest()!\nuploadRequest.body = url\nuploadRequest.key = remoteName\nuploadRequest.bucket = S3BucketName\nuploadRequest.contentType = \"image/jpeg\"\nuploadRequest.acl = .publicRead\n\u003c/pre\u003e\n\nAnd upload using \u003ci\u003eAWSS3TransferManager\u003c/i\u003e.\n\n\u003cpre\u003e\nlet transferManager = AWSS3TransferManager.default()\ntransferManager?.upload(uploadRequest).continue({ (task: AWSTask\u003cAnyObject\u003e) -\u003e Any? in\n  if let error = task.error {\n    print(\"Upload failed with error: (\\(error.localizedDescription))\")\n  }\n  if let exception = task.exception {\n    print(\"Upload failed with exception (\\(exception))\")\n  }\n  if task.result != nil {\n    let url = AWSS3.default().configuration.endpoint.url\n    let publicURL = url?.appendingPathComponent(uploadRequest.bucket!).appendingPathComponent(uploadRequest.key!)\n    print(\"Uploaded to:\\(publicURL)\")\n  }\n  return nil\n})\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2Fswift-amazon-s3-uploading-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximbilan%2Fswift-amazon-s3-uploading-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2Fswift-amazon-s3-uploading-tutorial/lists"}