-1

I'm trying to upload a file to an API with URLSessionUploadTask using method

uploadTask(with request: URLRequest, fromFile fileURL: URL) -> URLSessionUploadTask

Everything works perfect until file name doesn't contains semicolon.

When file name contains semicolon app start crashing with following error -

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot read file at file:///var/mobile/Containers/Data/Application/E647A171-A7CE-46D8-BE81-DB3626DD0157/Library/Caches/downloads/04405877-1554-744f-92ac-379c76300cd8/C8D67486-B79F-44C7-9295-768F0D4D0323/appium%20!@%23$%25%5E&-+=%7B%7Dl%5B%5D%20;'.,%20%20;%20logs%20-%20Copy%20(1).ppt'

FileName example which leads my app to crash:

"appium !@#$%^&_-+={}l[] ;\'.,_ ; logs - Copy (1).ppt"

";.pdf"

"];.ppt"

Please help if anybody ran into same problem. Thanks in advance.

Suryakant Sharma
  • 3,852
  • 1
  • 25
  • 47

1 Answers1

0

Can you please try with replacing ; to some text, and server side again with some text to ;

Example :-

if (filename contains ;) then filename replace with "SEMICOLON".

Application side when upload file :-

Real file name = ";.pdf"
New name when upload the file = "SEMICOLON.pdf"

Server side when save file in database :-

File name within response = "SEMICOLON.pdf"
New name when save in database = ";.pdf"

Shah Nilay
  • 778
  • 3
  • 21