Skip to content

Commit f0b9b73

Browse files
committed
feat: initial implementation
1 parent 475fe99 commit f0b9b73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2606
-603
lines changed

.github/workflows/github_actions.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ jobs:
2727
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
2828
- name: Code Coverage
2929
run: bundle exec fastlane coverage
30-
- name: Lint
31-
run: bundle exec fastlane lint
32-
- name: Setup sonarqube
33-
uses: warchant/setup-sonar-scanner@v8
34-
- name: Send to Sonarcloud
35-
run: bundle exec fastlane sonarqube
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
SONAR_TOKEN: ${{ secrets.SONARCLOUD_KEY }}
30+
# Commenting Lint steps for now, until we fix the workflow process
31+
# - name: Lint
32+
# run: bundle exec fastlane lint
33+
# Commenting Sonarqube steps for now, until we are able to configure Sonarqube in Ionic repos
34+
# - name: Setup sonarqube
35+
# uses: warchant/setup-sonar-scanner@v8
36+
# - name: Send to Sonarcloud
37+
# run: bundle exec fastlane sonarqube
38+
# env:
39+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
# SONAR_TOKEN: ${{ secrets.SONARCLOUD_KEY }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ fastlane/test_output
8888
# https://github.com/johnno1962/injectionforxcode
8989

9090
iOSInjectionProject/
91+
92+
# macOS system files
93+
.DS_Store

docs/CHANGELOG.md renamed to CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
### 2024-02-01
8-
- Fix: Update `github_actions.yml` file steps versions (https://outsystemsrd.atlassian.net/browse/RMET-2568).
7+
## [Unreleased]
98

10-
### 2022-04-12
11-
- Create repository.
9+
### 2025-04-14
10+
11+
- Implement native library with methods `downloadFile` and `uploadFile`.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
source "https://rubygems.org"
22

33
gem "fastlane"
4-
gem "slather"
4+
gem "slather"

IONFileTransferLib.podspec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Pod::Spec.new do |spec|
2+
spec.name = 'IONFileTransferLib'
3+
spec.version = '1.0.0'
4+
5+
spec.summary = 'A native iOS library for download and upload files.'
6+
spec.description = 'A Swift library for iOS that provides simple way to download and upload files. Download and upload files with a secure, clean and modern API.'
7+
8+
spec.homepage = 'https://github.com/ionic-team/ion-ios-filetransfer'
9+
spec.license = { :type => 'MIT', :file => 'LICENSE' }
10+
spec.author = { 'OutSystems Mobile Ecosystem' => '[email protected]' }
11+
12+
spec.source = { :http => "https://github.com/ionic-team/ion-ios-filetransfer/releases/download/#{spec.version}/IONFileTransferLib.zip", :type => "zip" }
13+
spec.vendored_frameworks = 'IONFileTransferLib.xcframework'
14+
15+
spec.ios.deployment_target = '14.0'
16+
spec.swift_versions = ['5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8', '5.9']
17+
end

IONFileTransferLib.xcodeproj/project.pbxproj

Lines changed: 588 additions & 0 deletions
Large diffs are not rendered by default.

IONFileTrasnsferLib.xcodeproj/xcshareddata/xcschemes/IONFileTrasnsferLib.xcscheme renamed to IONFileTransferLib.xcodeproj/xcshareddata/xcschemes/IONFileTransferLib.xcscheme

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
1717
BlueprintIdentifier = "7507FC1127FC2AAE003809F6"
18-
BuildableName = "IONFileTrasnsferLib.framework"
19-
BlueprintName = "IONFileTrasnsferLib"
20-
ReferencedContainer = "container:IONFileTrasnsferLib.xcodeproj">
18+
BuildableName = "IONFileTransferLib.framework"
19+
BlueprintName = "IONFileTransferLib"
20+
ReferencedContainer = "container:IONFileTransferLib.xcodeproj">
2121
</BuildableReference>
2222
</BuildActionEntry>
2323
</BuildActionEntries>
@@ -34,9 +34,9 @@
3434
<BuildableReference
3535
BuildableIdentifier = "primary"
3636
BlueprintIdentifier = "7507FC1927FC2AAE003809F6"
37-
BuildableName = "IONFileTrasnsferLibTests.xctest"
38-
BlueprintName = "IONFileTrasnsferLibTests"
39-
ReferencedContainer = "container:IONFileTrasnsferLib.xcodeproj">
37+
BuildableName = "IONFileTransferLibTests.xctest"
38+
BlueprintName = "IONFileTransferLibTests"
39+
ReferencedContainer = "container:IONFileTransferLib.xcodeproj">
4040
</BuildableReference>
4141
</TestableReference>
4242
</Testables>
@@ -62,9 +62,9 @@
6262
<BuildableReference
6363
BuildableIdentifier = "primary"
6464
BlueprintIdentifier = "7507FC1127FC2AAE003809F6"
65-
BuildableName = "IONFileTrasnsferLib.framework"
66-
BlueprintName = "IONFileTrasnsferLib"
67-
ReferencedContainer = "container:IONFileTrasnsferLib.xcodeproj">
65+
BuildableName = "IONFileTransferLib.framework"
66+
BlueprintName = "IONFileTransferLib"
67+
ReferencedContainer = "container:IONFileTransferLib.xcodeproj">
6868
</BuildableReference>
6969
</MacroExpansion>
7070
</ProfileAction>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import Foundation
2+
3+
/// A base delegate class for common upload and download task behaviors in a `URLSession`.
4+
///
5+
/// `IONFLTRBaseDelegate` provides shared logic for handling task completion and HTTP redirection.
6+
/// It is intended to be subclassed by specific delegates like `IONFLTRDownloadDelegate` and `IONFLTRUploadDelegate`.
7+
///
8+
/// This class communicates progress, success, and failure through a provided `IONFLTRPublisher`.
9+
///
10+
/// - Note: This class does not conform to any URLSession delegate protocols directly. Subclasses should conform to the appropriate protocols as needed.
11+
class IONFLTRBaseDelegate: NSObject {
12+
13+
/// The publisher used to send progress, success, and failure updates.
14+
let publisher: IONFLTRPublisher
15+
16+
/// A flag indicating whether HTTP redirects should be disabled.
17+
let disableRedirects: Bool
18+
19+
/// Initializes a new instance of the `IONFLTRBaseDelegate` class.
20+
///
21+
/// - Parameters:
22+
/// - publisher: The publisher used to communicate task updates.
23+
/// - disableRedirects: A flag indicating whether HTTP redirects should be disabled. Defaults to `false`.
24+
init(publisher: IONFLTRPublisher, disableRedirects: Bool = false) {
25+
self.publisher = publisher
26+
self.disableRedirects = disableRedirects
27+
}
28+
29+
/// Handles the completion of a URL session task.
30+
///
31+
/// This method checks for errors and evaluates the HTTP response. If the response code indicates a failure (non-2xx),
32+
/// it emits a failure event through the publisher with a structured `IONFLTRException`.
33+
///
34+
/// - Parameters:
35+
/// - task: The `URLSessionTask` that completed.
36+
/// - error: The error that occurred, if any.
37+
func handleCompletion(task: URLSessionTask, error: Error?) {
38+
if let error = error {
39+
publisher.sendFailure(error)
40+
return
41+
}
42+
43+
guard let response = task.response as? HTTPURLResponse,
44+
!(200...299).contains(response.statusCode) else {
45+
return
46+
}
47+
48+
let headers = response.allHeaderFields.reduce(into: [String: String]()) { result, element in
49+
if let key = element.key as? String, let value = element.value as? String {
50+
result[key] = value
51+
}
52+
}
53+
54+
publisher.sendFailure(
55+
IONFLTRException.httpError(
56+
responseCode: response.statusCode,
57+
responseBody: nil,
58+
headers: headers
59+
)
60+
)
61+
}
62+
63+
/// Handles HTTP redirection behavior.
64+
///
65+
/// This method determines whether or not to allow an HTTP redirect based on the `disableRedirects` flag.
66+
///
67+
/// - Parameters:
68+
/// - response: The `HTTPURLResponse` that triggered the redirection.
69+
/// - request: The new `URLRequest` to which the task is being redirected.
70+
/// - completionHandler: A closure that receives the request to continue with or `nil` to block the redirect.
71+
func handleRedirect(
72+
response: HTTPURLResponse,
73+
request: URLRequest,
74+
completionHandler: @escaping (URLRequest?) -> Void
75+
) {
76+
completionHandler(disableRedirects ? nil : request)
77+
}
78+
}

0 commit comments

Comments
 (0)