how can I read a file out of sandbox? (swift 5 , xcode 12) - swift5

I need to send a file to the server. I select this file with UIViewControllerRepresentable which provides the url of the file and every time I try to upload I get the same message :- Domain=NSCocoaErrorDomain Code=257 "The file “example1.xml” couldn’t be opened because you don’t have permission to view it." . I think I need to add permissions on info.plist but I don't find the right one. If I select a file in the sandbox it works.

I solved it by using .startAccessingSecurityScopedResource () on the URL. Eg:
`var path = URL (string: "pathFile")!
//before reading the file
path.startAccessingSecurityScopedResource ()
//at the end
path.stopAccessingSecurityScopedResource ()
//to close. `
resources https://developer.apple.com/documentation/foundation/nsurl/1417051-startaccessingsecurityscopedreso

Related

AWS S3 storage does not give a valid URL after uploading file

I am new to AWS. I use Amplify to upload a video file to S3 storage using Flutter. I want to get the URL after uploading a video to use it elsewhere. I use Amplify.Storage.getUrl(key)).url to get the URL. But when I want to go to the link via the browser, it shows the following error there:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>No AWSAccessKey was presented.</Message>
<RequestId>AK49EW70AR8N1NVC</RequestId>
<HostId>Z6FBLU/GABRvJKFX827m3HoIKfVIpU0iXmH3gwSpcu04nNiqqEFjHZGGLn3VyyVNMY7ndK541ro=
</HostId>
</Error>
And also this link doesn't work when I want to play a video using VideoPlayerController.network(videoUrl).
So what is the solution to get a general URL for the video file uploaded that can be used elsewhere? Thanks in advance.

Cannot use silent APNs with Firebase default authUI, always exception

In my Xcode Project I enabled APNs and in the Firebase Console I uploaded the correct APN Key. Still if I initiate the Phonenumber Login Process(with the prebuilt UI) it gives me an exception saying, that I need to add the URL-Type for the ReCaptcha.
How do I configure it to use silent APNs instead?
Error:
Exception: "Please register custom URL scheme 'com.googleusercontent.apps.*******'
in the app's Info.plist file."
Thank you!
Right click on the Info.plist
Choose Open as Source code
Add that to the list inside the :
CFBundleTypeRole
Editor
CFBundleURLSchemes
com.googleusercontent.apps.your-app-id-here
Full doc can be found here Firebase doc

Roxyfileman filemanager integration

I am trying to integrate roxyfileman filemanager with tinymce 4. When I click on filemanager I can able to see filemanager, But when I select any image I am getting below error message in console. and image is also not getting inserted.
Error: Permission denied to access property 'document'
Please advice.
Later I found, open manager. It doesn't require any configuration nothing. All you need to do is just download from below link and place it into your project folder. Thats it.
Reference: http://www.designsandcode.com/261/open-manager-tinymce-file-manager/

Programmatically downloading image from CQ5

I am trying to programmatically download a image from CQ5.I have made a link which when clicked should download a image.To do this I have made a ajax call to a servlet ,for whenever user clicks on the image,we should get a pop of open and save dialog.
This is the code I have written in servlet to download the image.
**response.setContentType("image/png");
response.setHeader("Content-Disposition", "attachment; filename=icon" + ".png");
URL url = new URL("http://somehost:portnmuber/content/dam/image.jpg");
URLConnection connection = url.openConnection();
InputStream stream = connection.getInputStream();**
I am continuously getting 401 error.
Is there some another way that I can do this.
Thanks,in advance.
Firstly, have a look at the download component in the foundation libs:
/libs/foundation/components/download/download.jsp
Secondly, if you don't have a session open with CQ5, it will by default give you a 401 error. I am assuming you are in a generated container for CQ5, or are you just randomly accessing from another domain?
Note that even for anonymous access, CQ will still establish an anonymous session, and give you a login token. Anonymous is effectively still authenticated, just without the requirement of a username and password.
You are gettin 401 error because anonymous user permissions for the DAM are not set.
At first, you should grant access permissions for 'anonymous' users for node '/content/dam'.
You can do it from the page: "http://somehost:portnuber/useradmin" . Doble click on user 'anonymous' and go to the tab 'permissions' (on the window right). Check read permissions for 'dam' node.
Secondly, go to the system console, components tab (http://somehost:portnmuber/system/console/components) and find org.apache.sling.engine.impl.auth.SlingAuthenticator component. Click to 'configure' button. In the component configuration check 'Allow Anonymous Access' and press 'Save'.
Should work.
CQ5 uses sessions so downloading from a path requires a username/password on the author instance, for example curl -u username:password http://someserver.com:4502/etc/packages/my_packages/package.zip -o localpath/package.zip would download a package based on someone who had permissions to read it. For images you need the image path something like http://someserver.com:4502/content/dam/640x960.jpg to get the image, but you would need to add /jcr:content/renditions/original to get the original e.g. http://someserver.com:4502/content/dam/640x960.jpg/jcr:content/renditions/original. You can also change the image path to get a specific rendition of the image, for example http://someserver.com:4502/content/dam/640x960.jpg/jcr:content/renditions/cq5dam.thumbnail.140.100.png gets a 140x100 version of the image.
I had a similar issue trying to download images from AEM to iOS devices. It turns out AEM (at least the instance I'm hitting) requires a referer header; if absent the request is rejected. The problem did not surface with the simulator, just with real devices. This did the trick:
[request setValue: #"https://www.example.com/" forHTTPHeaderField: #"Referer"];

In phonegap 1.4.1 in iOS6 unable to attach xml file from to mail client

to get help , I followed this post http://www.thoughtsonmobile.com/category/development/crossplattform-app-development
My objective is to use PhoneGap 1.4.1 plugin in iOS to write to an XML file and send that xml file via attachment in mail client
I am able to create an empty XML file in the path /var/mobile/Applications/D7558E05-1345-443E-A2E6-.../Document/readme.xml which I verified under Iexplorer to be under the Documents folder
I followed the steps in the mentioned site, exactly, but there is one confusion on how to pass the path to the Phonegap.exec command.. Should I pass the complete path "/var/mobile/Applications/D7558E05-1345-443E-A2E6-.../Document/readme.xml"
should I pass as follows
window.plugins.emailComposer.showEmailComposerWithCB(null, "subject", "body", "hello#gmail.com","ccsupport#test.com","bccsupport#test.com", false,XMLFilePath);
where
var XMLFilePath = window.rootFS.fullPath + "/" + "readme.xml";
or should it be just XMLFilePath = window.rootFS.fullPath
As mentioned in the site, in the EmailComposer.js I added
if(attachment)
args.attachment = attachment;
and checked, by alerting if the args.attachment is getting the path, its coming as /var/mobile/Applications/D7558E05-1345-443E-A2E6-.../Document/readme.xml
I added snippet as per the site, "NSString* attachmentPath = [options valueForKey...."to the EmailComposer.m code from "https://github.com/phonegap/phonegap-plugins/blob/master/iOS/EmailComposer/EmailComposer.m" which I am using
When I run the code I am NOT getting the attachment, am oly getting the subject, to and body
Please help
It would be very useful if you could upload a sample, complete xcode project for mail attachment.