File tree Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change 99import Foundation
1010
1111extension Data : Uploadable {
12+ public var filename : String ? {
13+ return nil
14+ }
15+
1216 public var size : UInt64 ? {
1317 return UInt64 ( count)
1418 }
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ import Foundation
1010import MobileCoreServices
1111
1212extension 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
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import Foundation
1010
1111/// The protocol any uploadables must conform to.
1212public 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.
You can’t perform that action at this time.
0 commit comments