wrong file name save in document directory in swift

55 Views Asked by At

When I save file in document directory as a normal text then its working proper but when I save with funcy font then my document directory path is wrong

let url = NSURL(string: path!.path)
let imagePath = url!.appendingPathComponent(imageName)
let urlString: String = imagePath!.absoluteString
let imageData = image.jpegData(compressionQuality: 1.0)
fileManager.createFile(atPath: urlString as String, contents: imageData, attributes: nil)

for example i set imageName is "hdhfhdhd.jpg" its generate proper path like this

"/private/var/mobile/Containers/Shared/AppGroup/4CA20503-AFA6-41F5-AADF-F42B1BF91303/CustomTheme/hdhfhdhd.jpg"

but when set imageName Like ".jpg" its generate path like this

"/private/var/mobile/Containers/Shared/AppGroup/4CA20503-AFA6-41F5-AADF-F42B1BF91303/CustomTheme/%F0%9D%95%99%F0%9D%95%95%F0%9D%95%99%F0%9D%95%97%F0%9D%95%99%F0%9D%95%95%F0%9D%95%99%F0%9D%95%95.jpg"

I want this type of path.

"/private/var/mobile/Containers/Shared/AppGroup/4CA20503-AFA6-41F5-AADF-F42B1BF91303/CustomTheme/.jpg"

Thanks...

0

There are 0 best solutions below