Flutter: Permission denied writing file - io

I am having a problem writing a file in Flutter. I keep getting this error:
FileSystemException: Cannot create file, path = '/data/local/tmp/temp.png' (OS Error: Permission denied, errno = 13)
For some reason, it's only happening on some devices. I can't seem to duplicate the problem myself, but people are reporting it to me.
Here's the basic code:
final Io.Directory systemTempDir = Io.Directory.systemTemp;
final Io.File file = await new Io.File('${systemTempDir.path}/temp.png').create();
file.writeAsBytes(finalImage);

In Android Q, just add the Following Lines in AndroidManifest file:
<application
android:requestLegacyExternalStorage="true"

There may be a problem with the paths depending on the device being used. Have a look at the path_provider plugin: https://pub.dartlang.org/packages/path_provider
There's a good write-up of how to read and write files in the Flutter Cookbook on flutter.io: https://flutter.io/cookbook/persistence/reading-writing-files/

final Io.Directory systemTempDir = Io.Directory.systemTemp; seems to not work in release mode.
I had to do as below:
Directory tempDir = await getTemporaryDirectory();
final File file = File("${tempDir.path}/$fileName");
getTemporaryDirectory() is provided by path_provider.

Related

Linux:load error:No such file or directory

I am deploying a web server, and after I finish compiling.There are the executing documents;
01client.c client epoll_server.c server
Then I try to run server
./server
There is an error which I cant fix it. I have search ways for solving but still can't fix it.
load error: No such file or directory
Maybe some one can help me,please!
Thanks a lot!!!!
System utilities print the program generating the error at the beginning of the line followed by other useful information such as the name of the missing file, so this is probably an error from a user program. I can duplicate the error as follows:
errno = 2;
perror("load error");
which prints:
load error: No such file or directory
Look for the perror line in the server code. If it isn't clear what file it can't find, print the string from the failed command it is reporting.

How do I resolve a permission error with django?

I am using Django to display my code in an html format using class based views. My code reads a log file and displays stats based on what is in there. When I try to access the log file from my computer this error message is displayed:
[Errno 13] Permission denied: 'C:/Users/bhattaar/Downloads/access.log'
I first tried going through the properties of the folder to make sure everything was set to read only (which it already was) and then I tried running the command prompt as an administrator and it still would not work.
The line the error appears on is this:
log = open('C:/Users/bhattaar/Downloads/access.log', 'r')
Does anyone know how I can resolve this issue?
Does this work?
Taken from here
log_file = r'C:/Users/bhattaar/Downloads/access.log'
with open(log_file) as f:
f = f.readlines()

How to define a file in Kotlin

I need to use a xml file in my code,
in Java it looks like this:
File inputFile = new File("test.xml"); //Path: C:\Users\...
however, when i try the same in kotlin, it does not work:
val inputFile = File("test.xml")
I always get an "File not found" exception.
I can't find anything on google on how to include files with Kotlin.
val inputStream: InputStream = File("test.xml").inputStream()
val inputString = inputStream.bufferedReader().use { it.readText() }
println(inputString)
Source : kotlination.com
The file must be in the root of your project, the same folder containing your src/ folder.
These should give the exact same results, if you run both with the same working directory. You can check or set the working directory (relative to which file.xml will be looked for) in the Run/Debug configuration.
Since you have Android Studio tag: if you are creating an Android application/library and want the file to be included with it, you should read https://developer.android.com/guide/topics/resources/index.html.

Kohana framework Fatal error mystery

I got a fatal error at auto_load function. See the following error, indicating that the specific directory and file '/mnt/webDir/www/sossage/system/classes/kohna/log.php' file failed opening required. Yes, file doesn't exist. Its's wrong path.
But, I never write the code, also can't find anywhere using 'find' option on my web root.
Fatal error: Kohana_Core::auto_load(): Failed opening required '/mnt/webDir/www/mysite/system/classes/kohna/log.php' (include_path='.:/usr/share/php:/usr/share/pear') in /mnt/webDir/mysite/system/classes/kohana/core.php on line 418, referer:
How can I solve the problem, please let me know the solution or tips.
Thanks.
You've got a typo in your configuration, likely. Note the directory it's attempting to access:
...system/classes/kohna/log.php
"kohna" is not the appropriate spelling. The directory is instead:
...system/classes/kohana/

eclipse : impossible to import git project

I got a problem with my eclipse, on debian.
When I try to import a git project from github, using egit I got a
Couldn't create temporary repository.
error after having set my project properties.
However, I works ok when using running eclipse with sudo.
I think it would be related to wrong permissions somewhere, but cannot figure out where :s
I would appreciate some help.
Thanks by advance !
Considering the source of org.eclipse.egit.ui.internal.clone.SourceBranchPage.java mentions /tmp, it should be related with some permission issue around /tmp.
try {
final URIish uri = newRepoSelection.getURI();
final Repository db = new Repository(new File("/tmp"));
listRemoteOp = new ListRemoteOperation(db, uri);
getContainer().run(true, true, listRemoteOp);
} catch (IOException e) {
transportError(UIText.SourceBranchPage_cannotCreateTemp);
return;
}
The OP jlengrand actually reports in the comments:
The problem was simple in fact, but quite handy to track down:
My .gitconfig file had been corrupted during my debian upgrade, which caused egit to crash.

Resources