Skip to content

Commit 649dbf8

Browse files
committed
Using a fixed chunk size depending on upload type.
1 parent 00fe54a commit 649dbf8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

FilestackSDK/Internal/Uploaders/MultipartUpload.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ extension MultipartUploadError: LocalizedError {
2828
}
2929
}
3030

31+
/// Chunksize depending on upload type.
32+
enum ChunkSize: Int {
33+
/// Regular (5 megabytes)
34+
case regular = 5_242_880
35+
/// Intelligent Ingestion (8 megabytes)
36+
case ii = 8_388_608
37+
}
38+
3139
/// This class allows uploading a single `Uploadable` item to a given storage location.
3240
class MultipartUpload: Uploader {
3341
typealias UploadProgress = (Int64) -> Void
@@ -192,12 +200,11 @@ private extension MultipartUpload {
192200
canUseIntelligentIngestion = false
193201
}
194202

195-
let chunkSize: Int = options.chunkSize
196-
197203
var part: Int = 0
198204
var seekPoint: UInt64 = 0
199205
var partsAndEtags: [Int: String] = [:]
200206

207+
let chunkSize = (canUseIntelligentIngestion ? ChunkSize.ii : ChunkSize.regular).rawValue
201208
let beforeCompleteCheckPointOperation = BlockOperation()
202209

203210
beforeCompleteCheckPointOperation.completionBlock = {

FilestackSDK/Public/Models/UploadOptions.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ import Foundation
1919
/// An object containing the store options (e.g. location, region, container, access, etc.)
2020
@objc public var storeOptions: StorageOptions
2121

22-
/// The chunksize in bytes to use.
23-
@objc public var chunkSize: Int
24-
2522
/// How many parts should be uploaded concurrently
2623
@objc public var partUploadConcurrency: Int
2724

@@ -32,20 +29,15 @@ import Foundation
3229
@objc public init(preferIntelligentIngestion: Bool,
3330
startImmediately: Bool,
3431
storeOptions: StorageOptions = .defaults,
35-
chunkSize: Int = UploadOptions.defaultChunkSize,
3632
partUploadConcurrency: Int = UploadOptions.defaultPartUploadConcurrency,
3733
chunkUploadConcurrency: Int = UploadOptions.defaultChunkUploadConcurrency) {
3834
self.preferIntelligentIngestion = preferIntelligentIngestion
3935
self.startImmediately = startImmediately
4036
self.storeOptions = storeOptions
41-
self.chunkSize = chunkSize
4237
self.partUploadConcurrency = partUploadConcurrency
4338
self.chunkUploadConcurrency = chunkUploadConcurrency
4439
}
4540

46-
/// Default chunk size (5 megabytes)
47-
@objc public static var defaultChunkSize: Int = 5 * Int(pow(Double(1024), Double(2)))
48-
4941
/// Default part upload concurrency
5042
@objc public static var defaultPartUploadConcurrency: Int = 5
5143

0 commit comments

Comments
 (0)