Skip to content

Commit 8d355ac

Browse files
committed
Check chunksize value
1 parent 1961648 commit 8d355ac

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

VideoUploaderIos.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'VideoUploaderIos'
11-
s.version = '0.0.1'
11+
s.version = '0.0.2'
1212
s.summary = 'A library to upload video files to api.video platform.'
1313

1414
# This description is used to generate tags and improve search results.

VideoUploaderIos/Classes/VideoUploader.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ public class VideoUploader {
88
private var token: String! = ""
99
private var tokenType: String! = "Bearer"
1010

11-
private static let DEFAULT_CHUNK_SIZE = 1024 * 1024 * 5;
12-
private static let DEFAULT_USER_AGENT = "api.video uploader (ios; v:0.0.1; )";
11+
private static let MIN_CHUNK_SIZE = 1024 * 1024 * 5;
12+
private static let MAX_CHUNK_SIZE = 1024 * 1024 * 128;
13+
private static let DEFAULT_CHUNK_SIZE = 1024 * 1024 * 50;
14+
private static let DEFAULT_USER_AGENT = "api.video uploader (ios; v:0.0.2; )";
1315

1416
public init(host: String? = nil, chunkSize: Int? = nil, userAgent: String? = nil){
1517
self.host = host ?? "ws.api.video";
1618
self.chunkSize = chunkSize ?? VideoUploader.DEFAULT_CHUNK_SIZE
1719
self.userAgent = userAgent ?? VideoUploader.DEFAULT_USER_AGENT
1820

19-
if(self.chunkSize < VideoUploader.DEFAULT_CHUNK_SIZE) {
20-
print("Given chunk size is below the minimal allowed value. The default value will be used.");
21+
if(self.chunkSize < VideoUploader.MIN_CHUNK_SIZE || self.chunkSize > VideoUploader.MAX_CHUNK_SIZE) {
22+
print("Invalid chunk size value. Must be greater than 5MB bytes and lower than 128MB. The default value (50MB) will be used.");
2123
self.chunkSize = VideoUploader.DEFAULT_CHUNK_SIZE;
2224
}
2325
}

0 commit comments

Comments
 (0)