iOS unable to read/open file from the "Files" app when registered as a handler - filesystems

I have registered my App to open .ply files using "document types" and "imported type identifiers". My app gets the open URL callback and can open the file when shared using airdrop (200mb file).
My app is also listed when the user wants to open the file from the Files app. However, when I get the URL to the file selected in the "Files" app, I get an error saying I can not read the file. Can not copy or get a file handle.
I have the following keys in my plist:
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
How can my app open a file that it has registered as a handler, if the file resides in an arbitrary "Files" directory, and the user tapped on the file and selected my app as a handler?
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
//start loading file }
// inside file loader:
func prepare(toView file: URL) {
do {
let destination = self.scan.folderURL.appendingPathComponent("temporary_copy.ply")
if FileManager.default.fileExists(atPath: destination.path) {
try FileManager.default.removeItem(at: destination)
}
try FileManager.default.copyItem(at: file, to: destination)
} catch {
print("Error copying file: \(error)")
return
}
}

Related

My service is not recognizing the file names contained in directory with Java 8

I am creating a service and I am using java 8, I want to retrieve the file names as a list, those are in a folder into resources/ and when I am running locally is working but when I deployed my application into DEV/QA environment is getting empty, is not recognizing those files, and I have some considerations:
In the full path, in one folder is hidden folder (.cache), that
could affect it?, this is the path:
file:/newarch/apps/project-1/servers/project-service-1/workarea/org.eclipse.osgi/55/data/cache/com.ibm.ws.app.manager_723/.cache/project-service-ser.jar!/services
I gave rights on the folder as reader and writer.
This is the structure of the folder that I wanna retrieve the names:
resources/
services/
service-host1.js
service-host2.js
service-host3.js
service-host4.js
This is my code to read:
public List<String> getFilesFromDirectory(String dirName) throws IOException {
dirName = dirName + "/";
try (Stream<Path> pathStream = Files.list(Paths.get(dirName))) {
return pathStream.filter(Files::isRegularFile)
.map(Path::getFileName)
.map(Path::toString)
.collect(Collectors.toList());
}
}
this is the way how I am getting the full path:
Thread.currentThread().getContextClassLoader().getResource("service").getPath()
Could you give any advice what could be the problem?

Pick up files from multiple location using camel FTP

i have a situation i need to pick up files from two different location using camel FTP.
currently my code is
try {
from(format("sftp://%s#%s:22/../../..%s?password=%s&delete=true", ftpUserName, ftpServer, responsePath, ftpPassword ))
.filter(header("CamelFileName").endsWith(".PDF"))
.to(format("sftp://%s#%s:22/../../..%s/processed?password=%s", ftpUserName, ftpServer, responsePath, ftpPassword))
.process(documentProcessor)
/*.log(LoggingLevel.INFO, (org.slf4j.Logger) logger, "Download file ${file:name} complete.")*/
/*.to(downloadLocation)*/;
/*.to(format("smtp://relay.us.signintra.com?to=%s&from=noreply#dbschenker.com&subject=GTM response from cisco", emailTo))*/
;
} catch (Exception e) {
e.printStackTrace();
}
This is picking up the file that is mentioned in the application.properties files. How can i do this to puck up files from multile locations.
You can configure multiple FTP consumer routes and forward the message to shared direct-endpoint.
Example:
from("ftp:{{target.host}}:{{ftp.port}}/{{target.path1}}...")
.routeId("PollForFilesInPath1")
.to("direct:handleFileFromFTP");
from("ftp:{{target.host}}:{{ftp.port}}/{{target.path2}}...")
.routeId("PollForFilesInPath2")
.to("direct:handleFileFromFTP");
from("direct:handleFileFromFTP")
.routeId("handleFileFromFTP")
.log("file received from ftp: ${headers.CamelFileName }")
// Do stuff with the file
If you need to call 2 FTP consumer endpoints from single route you can use poll-enrich.

Ionic 4 file plugin copy from the assets folder to the default directory

I'm using the file plugin. and I created a folder called my_media in the default directory of my app.
let path = this.file.dataDirectory;
this.file.createDir(path,'my_media', false);
Now I wanna copy an image from the assets folder to the my_media folder.
let my_media = path + 'my_media'
this.file.copyFile('../assets','default.gif', my_media , 'default.gif').then((res)=>{
console.log("Default profile Copied Successfully")
}).catch(err=>{
console.log("Error to copy Image = ", err)
})
But I got this error
code: 5
message: "ENCODING_ERR"
It is not possible to copy from the assets folder to the app data directory. But I can use the file from the assets folder.

Dynamically Loading Plugin Configuration Files in CakePHP 3

Question: How do I load a configuration file from a Plugin/config Directory?
Demo Project: https://github.com/CakePHPKitchen/CakeDC-Users-Permissions-Example
I am using CakeDC/users plugin and it has a permissions.php file that it loads the RBAC permissions from. From what I can tell, it either loads the default permissions file that is in the user plugin's config folder OR it loads the permissions.php file from the app/config folder.
Now for my app skeleton I have a bunch of permissions in the app/config/permissions.php, however, I do not want to modify that file as I will be doing git pulls from the upstream repo and I would like to avoid conflicts.
So what I would like to do is, in the app skeleton bootstrap
I would like to
foreach(Plugin::loaded() as $plugin) {
$path = Plugin::path($plugin) . 'config/permissions.php';
if(file_exists($path)) {
Configure::load($path, 'default', true);
}
}
But I am getting the following error....
Error: The application is trying to load a file from the /Users/jlroberts/Projects/JeffreyLRobertsCom/CakePHPKitchen/PluginDemos/plugins/SharpAgent/config/permissions plugin.
Make sure your plugin /Users/jlroberts/Projects/JeffreyLRobertsCom/CakePHPKitchen/PluginDemos/plugins/SharpAgent/config/permissions is in the /Users/jlroberts/Projects/JeffreyLRobertsCom/CakePHPKitchen/PluginDemos/plugins/ directory and was loaded.
Any ideas on how I can load the permissions.php file from the Plugin/config directory?
EDITED: You can load permissions.php file from the Plugin as it is doing now, but change the contents of permissions.php to preserve existing permissions defined in configuration, for example:
config/permissions.php
$permissions = [
// add your app permissions here
[
// ...
],
];
// there are more permissions in this config key, defined across your plugins
$morePermissions = \Cake\Core\Configure::read('MyPermissions');
$allPerms = array_merge($permissions, $morePermissions);
return ['CakeDC/Auth.permissions' => $allPerms];
Then inside each plugin you could have:
YOUR_PLUGIN/config/bootstrap.php
$permissions = \Cake\Core\Configure::read('MyPermissions');
$someMorePermissions = [
[
// permissions injected into the app from this plugin
]
];
$permissions = array_merge((array)$permissions, $someMorePermissions);
\Cake\Core\Configure::write('MyPermissions', $permissions);
Allowing each plugin to dynamically inject/manage permissions into the app.
I've created a c9.io environment with this code here https://ide.c9.io/steinkel/users-35-custom-permissions

Grails - logging from Quartz job and Filter

I would like to stock my logs into files:
Here is how I declare my appenders in Config.groovy:
log4j = {
appenders {
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
file name: "scraperServiceDetailedLogger",
file: "target/scraperServiceDetailed.log"
file name: "scraperServiceLogger",
file: "target/scraperService.log"
file name: "filterLogger",
file: "target/filter.log"
}
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
error scraperServiceDetailedLogger: "grails.app.service.personalcreditcomparator.ScraperService"
info scraperServiceLogger: "grails.app.jobs.personalcreditcomparator.ScraperJob"
info filterLogger: "grails.app.conf.personalcreditcomparator.AdministratorInterfaceProtectorFilters"
}
The 3 files are created properly but only scraperServiceDetailedLogger stores the logs properly. The other two files remain empty.
The level of logging is respected while calling the log.
What am I missing ?
Thank you for any help provided.
For quartz jobs try the Logger prefix of 'grails.app.task'
info scraperServiceLogger: "grails.app.task.personalcreditcomparator.ScraperJob"
And for filters try the Logger prefix of 'grails.app.filters'
info filterLogger: "grails.app.filters.personalcreditcomparator.AdministratorInterfaceProtectorFilters"

Resources