Skip to content

Commit bbbb66b

Browse files
author
Ruben Nine
committed
Merge branch 'develop' of github.com:filestack/filestack-swift into develop
2 parents 8a69539 + dd62ce1 commit bbbb66b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

FilestackSDK/Internal/Uploaders/MultipartUpload.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private extension MultipartUpload {
154154
func doUploadFile() {
155155
currentStatus = .inProgress
156156

157-
let fileName = options.storeOptions.filename ?? UUID().uuidString
157+
let fileName = options.storeOptions.filename ?? uploadable.filename ?? UUID().uuidString
158158
let mimeType = options.storeOptions.mimeType ?? uploadable.mimeType ?? "text/plain"
159159

160160
guard let fileSize = uploadable.size, !fileName.isEmpty else {

FilestackSDK/Public/Extensions/Data+Uploadable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
import Foundation
1010

1111
extension Data: Uploadable {
12+
public var filename: String? {
13+
return nil
14+
}
15+
1216
public var size: UInt64? {
1317
return UInt64(count)
1418
}

FilestackSDK/Public/Extensions/URL+Uploadable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import Foundation
1010
import MobileCoreServices
1111

1212
extension URL: Uploadable {
13+
public var filename: String? {
14+
return lastPathComponent
15+
}
16+
1317
public var size: UInt64? {
1418
guard let attributtes = try? FileManager.default.attributesOfItem(atPath: relativePath) else { return nil }
1519

FilestackSDK/Public/Protocols/Uploadable.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import Foundation
1010

1111
/// The protocol any uploadables must conform to.
1212
public protocol Uploadable {
13+
/// The fileName of this uploadable, or `nil` if unavailable.
14+
var filename: String? { get }
1315
/// The size of this uploadable in bytes, or `nil` if unavailable.
1416
var size: UInt64? { get }
1517
/// The MIME type of this uploadable, or `nil` if unavailable.

0 commit comments

Comments
 (0)