I have downloaded a file to getApplicationDocumentsDirectory().
Then I have inserted the file path to a SQLite database.
In this case the file is a png file, and I need to show it on a screen.
I am trying to do it as follows:
Container(color: Colors.grey[200],
child: Image.file(File(${snapshot.data![position].path})),
alignment: Alignment.center
)
I am geting an exception:
FileSystemException: Cannot open file, path=//var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
I have checked if the path from the downloaded file is equal to the path from the SQLite item value, and both are equal.
Downloaded file path print output:
flutter: path al archivo descargado /var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
SQLite path value :
path en docs: /var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
I have also tested putting that path as text directly into
Image.file(File("/var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png"))
and it works.
I donĀ“t find the reason for not showing the image when using the value snapshot.data![position].path, knowing that it is the same value.
In the exception, I can see that there is a leading / sign in the path which might be the problem.
FileSystemException: Cannot open file, path=//var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
Related
Not sure exactly what's going wrong here, but I've added my assets directory in my project folder and added it to the pubspec.yaml but when I try to read the csv file it get the above error.
final posts = File('assets/posts.csv').readAsLinesSync().map((lines) {
final parts = lines.split(',');
return Post(
title: parts[0],
numDownVotes: int.tryParse(parts[1]),
numUpVotes: int.tryParse(parts[2]),
);
}
).toList();
How often and for what reason does the csv file get updated? Given that your code refers to down and up votes, I guess that it is changed often. In which case it is not an asset. The assets folder contains things that are incorporated into your app only when it is built. It is not used when you run the app, the csv file needs to be written to and read from the devices local storage....as #gwhyyy indicates.
hello evryone
wanna load file from a specific path writen in an edit box named by 'Load_text', i got the path from the edit box using :
pth=get(handles.Load_text,'string');
then i used 'dir' as follow:
S=dir(fullfile([pth '*.bmp']));
that what cause me an errur . so any ideas ?
If you want to load a file then why you are using dir?
Since you have the file's name, then you can create the fullpath as you do with the fullpath method and check its existence with exists.
If the file exists, then you can load it with all available methods from MATLAB.
Keep in mind that this means that the file is in the same directory as your GUI files. If it is in another then you will have to add it in the fullpath call.
fullpath online doc: http://www.mathworks.com/help/matlab/ref/fullfile.html
exists online doc: http://www.mathworks.com/help/matlab/ref/exist.html
Can someone please explain to me what the code below isnt working?
myFolderdepth = 'C:\Users\owner\Desktop'; %Specify Directory to get image from
Depth = dir (fullfile(myFolderdepth,'shower_depth','*.png'))%%Get images from file named shower_depth
Depth_name = {Depth.name}'; %gets the name
figure;
imshow(Depth_name{3})
The error message I get is as follows:
Error using getImageFromFile (line 11)
Cannot find the specified file:
"Depth_003.png".
The directory I am working in is: C:\Users\owner\Desktop
The name of the pictures are Depth_001,Depth_002,Depth_003,......
Oddly enough, I have another folder that has images and if I change the 'shower_depth' to the other folder name, it works fine.
Thank you!
P.S I did some further experimentation, it turns out its because of the way the image is named; if its Depth_01.png thats fine it works but Depth_001.png is not okay
Anyone knows why?
The following command:
Depth = dir (fullfile(myFolderdepth,'shower_depth','*.png'))
only gets the relative names of the files. This means that the file names are only retrieved, not the full path to the file. Take a look at the error that you're getting:
Error using getImageFromFile (line 11)
Cannot find the specified file: "Depth_003.png".
Do you see the path of where your images in the above file name? Nope! You only see the file stored in the directory. You need to specify the full path of where the image is located.
What you need to do is append the directory as well as the image itself as the string you supply to imshow:
myFolderdepth = 'C:\Users\owner\Desktop'; %Specify Directory to get image from
Depth = dir (fullfile(myFolderdepth,'shower_depth','*.png'))%%Get images from file named shower_depth
Depth_name = {Depth.name}'; %gets the name
figure;
imshow(fullfile(myFolderDepth, Depth_name{3})); %// CHANGE HERE
Depth_name is only the image name. You have to read the image before show it. The modified code is below:
im = imread(Depth_name{3});
imshow(Depth_name{3});
I am trying to get an image uploaded by user, store it in a folder(for which I am providing absolute path), store the path in database(Relative path) abd later use the path from database todisplay the image.
I am using cos-MultipartRequest jar file for this.
I don't want to have spaces in the file name(Since the image with spaces in name is not displayed by <img>)
The code I have written is:
String pathUPLOAD="D:/AdvJava/proimp/WebContent/images/default";
String pathDB="images/default";
MultipartRequest m=new MultipartRequest(request,pathUPLOAD);
String file=m.getFilesystemName("file").replaceAll("\\s+",""); //to remove spaces
m.getFile("file").renameTo(new File(pathDB+file)); // to rename the uploaded file without whitespaces
//(tried this earlier) m.getFile("file").renameTo(new File(file));
the path I am inserting in DB is: pathDB+"/"+file
The upload works fine and later the images are also displayed for those which don't have spaces in name.
But for those having spaces, the path stored in DB is the way I want, but the image uploaded in the specified directory does not has any changes in its name and therefore the place where images are to be displayed shows a missing image.
Any suggestions?
i m creating a project in gwt (point) is project name ...
i want to store a image in point/war/images folder, whaich i gave the full path like C:\Documents and Settings\computer\workspace\m\war\images\ tthe the iamge will stored in images folder but i want to give the default path
i give "../war/images/" as default path, but this give me error (he system cannot find the path specified )
can any body help to give the default path
Usually you put images in the war/images directory, and you access them like
Image img = new Image("images/my_image.jpg")
You may also read this thread, and this question.