Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS 13 Upload encounter Error Domain=NSCocoaErrorDomain Code=257 #245

Closed
2 of 3 tasks
tim70312 opened this issue Oct 16, 2019 · 6 comments
Closed
2 of 3 tasks

IOS 13 Upload encounter Error Domain=NSCocoaErrorDomain Code=257 #245

tim70312 opened this issue Oct 16, 2019 · 6 comments

Comments

@tim70312
Copy link

Bug Report

fileTransfer.upload(...) returns an error with code = 1. Works well with IOS 12.4.

Problem

While calling fileTransfer.upload() to upload a video,it return error code 1

code = 1;
source = "file:///private/var/mobile/Containers/Data/PluginKitPlugin/FABA3640-0F94-496D-94BC-85A8ED5241F6/tmp/trim.8466A661-EB72-45FC-9622-4E30AA1C1D3A.MOV";
target = "myService";

What is expected to happen?

Upload data with video successfully to a remote server.(Works well with IOS 12.4)

What does actually happen?

I found the problem is at this line.
NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
Here's the error log

myapp[1222:123456] Error opening file file:///private/var/mobile/Containers/Data/PluginKitPlugin/FABA3640-0F94-496D-94BC-85A8ED5241F6/tmp/trim.8466A661-EB72-45FC-9622-4E30AA1C1D3A.MOV: Error Domain=NSCocoaErrorDomain Code=257 "The file “trim.8466A661-EB72-45FC-9622-4E30AA1C1D3A.MOV” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/FABA3640-0F94-496D-94BC-85A8ED5241F6/tmp/trim.8466A661-EB72-45FC-9622-4E30AA1C1D3A.MOV, NSUnderlyingError=0x28199f2d0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

It seems that apple change the way of dealing NSData

Information

I'm using xcode11 and complie to my IOS 13.1.2 device.

Command or Code

            fileTransfer.upload(_videoURL,  encodeURI(strServerURI), funUploadSuccess, captureError, _videoOption);

Environment, Platform, Device

Testing on iPhone8 with iOS version 12.3.2.
iPhoneX with iOS version 12.4.

Version information

MacOS Mojave 10.14.4
XCode 11
Cordova 9.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@rituparnaGuha
Copy link

Hello
I have same issue..unable to upload video from gallery in ionic 3 app.

@timbru31
Copy link
Member

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

@BekirBesli
Copy link

Hello
I have same issue. İ dont undertsand your solve timbru31 ?
can you elaborate your description?

@BekirBesli
Copy link

apache/cordova-plugin-camera#506 (comment)
this work for me .

@breautek
Copy link
Contributor

There's been several reports among plugins that interact with the file system on iOS 13 such as the issue @BekirBesli related to urls returning a /private/ url instead of a /var/ url and I suspect this is the same kind of issue.

@tim70312
Copy link
Author

@BekirBesli You really saved my day.
That solution works for me.

@tim70312 tim70312 closed this as completed Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants