@@ -14,7 +14,11 @@ import XCTest
1414class FileLinkTests : XCTestCase {
1515 private let cdnStubConditions = isScheme ( Constants . cdnURL. scheme!) && isHost ( Constants . cdnURL. host!)
1616 private let apiStubConditions = isScheme ( Constants . apiURL. scheme!) && isHost ( Constants . apiURL. host!)
17- private let documentsPath = NSSearchPathForDirectoriesInDomains ( . documentDirectory, . userDomainMask, true ) [ 0 ]
17+
18+ private let downloadsDirectoryURL = try ! FileManager . default. url ( for: . downloadsDirectory,
19+ in: . userDomainMask,
20+ appropriateFor: nil ,
21+ create: true )
1822
1923 override func tearDown( ) {
2024 super. tearDown ( )
@@ -273,7 +277,7 @@ class FileLinkTests: XCTestCase {
273277 let fileLink = client. fileLink ( for: " MY-HANDLE " )
274278 let expectation = self . expectation ( description: " request should succeed " )
275279
276- let destinationURL = URL ( fileURLWithPath : documentsPath , isDirectory : true )
280+ let destinationURL = downloadsDirectoryURL
277281 . appendingPathComponent ( UUID ( ) . uuidString)
278282 . appendingPathExtension ( " jpg " )
279283
@@ -319,7 +323,7 @@ class FileLinkTests: XCTestCase {
319323 let expectedRequestURL = Constants . cdnURL. appendingPathComponent ( " MY-HANDLE " )
320324
321325 let expectation = self . expectation ( description: " request should fail with a 404 " )
322- let destinationURL = URL ( fileURLWithPath : documentsPath , isDirectory : true ) . appendingPathComponent ( " sample.jpg " )
326+ let destinationURL = downloadsDirectoryURL . appendingPathComponent ( " sample.jpg " )
323327 var response : FilestackSDK . DownloadResponse ?
324328
325329 fileLink. download ( destinationURL: destinationURL) { resp in
@@ -341,7 +345,7 @@ class FileLinkTests: XCTestCase {
341345 let client = Client ( apiKey: " MY-API-KEY " )
342346 let fileLink = client. fileLink ( for: " MY-HANDLE " )
343347 let expectation = self . expectation ( description: " request should succeed " )
344- let destinationURL = URL ( fileURLWithPath : documentsPath , isDirectory : true ) . appendingPathComponent ( " sample.jpg " )
348+ let destinationURL = downloadsDirectoryURL . appendingPathComponent ( " sample.jpg " )
345349 var response : FilestackSDK . DownloadResponse ?
346350
347351 fileLink. download ( destinationURL: destinationURL, parameters: [ " foo " : " 123 " , " bar " : " 321 " ] ) { resp in
@@ -378,7 +382,7 @@ class FileLinkTests: XCTestCase {
378382
379383 let client = Client ( apiKey: " MY-API-KEY " )
380384 let fileLink = client. fileLink ( for: " MY-HANDLE " )
381- let destinationURL = URL ( fileURLWithPath : documentsPath , isDirectory : true ) . appendingPathComponent ( " sample.jpg " )
385+ let destinationURL = downloadsDirectoryURL . appendingPathComponent ( " sample.jpg " )
382386 let progressExpectation = expectation ( description: " request should report progress " )
383387
384388 let downloadProgress : ( ( Progress ) -> Void ) = { progress in
0 commit comments