Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AWSS3StoragePlugin framework and AmplifyAppExample and podspecs #1

Merged
merged 2 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
# OS generated files #
######################
.COMPONENT_CACHED
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# Xcode setups
**/xcuserdata
**/*.xcuserdata

*.xcworkspace/
Amplify.xcodeproj/xcuserdata
Amplify.xcworkspace/xcuserdata
xcuserdata
xcuserdata

# Patched code #
######################
*.bak

# Built assets #
######################
build
builtFramework
AWS*.framework

# Stuff that can't be committed #
######################
credentials.json
Pods
Podfile.lock
Documentation
Scripts/build.sh
Scripts/gcovr
Scripts/jenkins.py
Scripts/ocunit2junit
__pycache__/
awsconfiguration.json
credentials-mc.json
27 changes: 27 additions & 0 deletions AWSS3StoragePlugin.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Be sure to run `pod spec lint AWSS3StoragePlugin.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

s.name = 'AWSS3StoragePlugin'
s.version = '0.0.1'
s.summary = 'Amazon Web Services Amplify for iOS.'

s.description = 'AWS Amplify for iOS provides a declarative library for application development using cloud services'

s.homepage = 'http://aws.amazon.com/mobile/sdk'
s.license = 'Apache License, Version 2.0'
s.author = { 'Amazon Web Services' => 'amazonwebservices' }
s.platform = :ios, '8.0'
s.source = { :git => 'https://github.com/aws-amplify/amplify-ios.git', :tag => s.version}

s.requires_arc = true
s.dependency 'Amplify', '0.0.1'
s.source_files = 'AWSS3StoragePlugin/**/*.swift'

end
51 changes: 51 additions & 0 deletions AWSS3StoragePlugin/AWSS3StorageGetOperation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Copyright 2018-2019 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import Foundation
import Amplify
import AWSS3

public class AWSS3StorageGetOperation: AmplifyOperation<Progress, StorageGetResult, StorageGetError>, StorageGetOperation {

var key: String

var refGetTask: AWSS3TransferUtilityDownloadTask?
var onEvent: ((AsyncEvent<Progress, StorageGetResult, StorageGetError>) -> Void)?
init(key: String) {
self.key = key
super.init(categoryType: .storage)
}

// implements Resumable
public func pause() {
self.refGetTask?.suspend()
}

// implements Resumbable
public func resume() {
self.refGetTask?.resume()
}

// override AmplifyOperation : Cancellable
override public func cancel() {
self.refGetTask?.cancel()
cancel()
}

func emitEvent(progress: Progress) {
self.onEvent?(AsyncEvent.inProcess(progress))
}

func emitSuccess(data: Data) {
let result = StorageGetResult(data: data)
self.onEvent?(AsyncEvent.completed(result))
}

override public func main() {

}
}
52 changes: 52 additions & 0 deletions AWSS3StoragePlugin/AWSS3StoragePlugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright 2018-2019 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import Amplify
import AWSS3

public class AWSS3StoragePlugin : StorageCategoryPlugin {

private let queue: OperationQueue = OperationQueue()

public init() {

}

public var key: PluginKey {
return "AWSS3StoragePlugin"
}

public func configure(using configuration: Any) throws {
if let configuration = configuration as? [String: Any] {
let bucket = configuration["Bucket"] as! String
let region = configuration["Region"] as! String
let credentialsProvider = configuration["CredentialsProvider"] as! [String:Any]
let poolId = credentialsProvider["PoolId"] as! String
let credentialsProviderRegion = credentialsProvider["Region"] as! String

let credentialProvider = AWSCognitoCredentialsProvider(regionType: credentialsProviderRegion.aws_regionTypeValue(), identityPoolId: poolId)
let serviceConfiguration: AWSServiceConfiguration = AWSServiceConfiguration(region: region.aws_regionTypeValue(), credentialsProvider: credentialProvider)

AWSS3TransferUtility.register(with: serviceConfiguration, forKey: key)
AWSS3PreSignedURLBuilder.register(with: serviceConfiguration, forKey: key)
AWSS3.register(with: serviceConfiguration, forKey: key)
}
}

public func reset() {
}


public func get(key: String, options: Any?) -> StorageGetOperation {
let operation = AWSS3StorageGetOperation(key: key)
queue.addOperation(operation)
return operation
}

public func stub() {
}
}
22 changes: 22 additions & 0 deletions AWSS3StoragePlugin/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
33 changes: 33 additions & 0 deletions AWSS3StoragePluginTests/AWSS3StoragePluginTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright 2018-2019 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import XCTest
@testable import AWSS3StoragePlugin

class AWSS3StoragePluginTests: XCTestCase {

override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
22 changes: 22 additions & 0 deletions AWSS3StoragePluginTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
26 changes: 26 additions & 0 deletions Amplify.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Be sure to run `pod spec lint Amplify.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

s.name = 'Amplify'
s.version = '0.0.1'
s.summary = 'Amazon Web Services Amplify for iOS.'

s.description = 'AWS Amplify for iOS provides a declarative library for application development using cloud services'

s.homepage = 'https://aws.amazon.com/amplify/'
s.license = 'Apache License, Version 2.0'
s.author = { 'Amazon Web Services' => 'amazonwebservices' }
s.platform = :ios, '9.0'
s.source = { :git => 'https://github.com/aws-amplify/amplify-ios.git', :tag => s.version}

s.requires_arc = true
s.source_files = 'Amplify/**/*.swift'

end
Loading