Show images from perticular folder in iOS - ios

I am using https://pub.dev/packages/flutter_image_gallery to show images stored in the particular folder but it is showing all images from the gallery is there any way that I can use it to show from a particular folder only

If you want specific directory location image then use ext_storage package. You can get all the files of the specific folder. You just have to separate it by extension. Please look at the code below so you can get idea. the code is same as shown in library.
void _example1() async {
var path = await ExtStorage.getExternalStorageDirectory();
print(path); // /storage/emulated/0
}

Related

How to show data in firebase cloud storage file? Mac OS

I would like to create a function that gets the data in my firebase cloud storage. For example, I have 3 separate folders as follows: Movies, Songs and previews. I would like to create a function that will be able to download the url file of the specified folder to get the data of it so I can display it on the selection screen. I have the folders pretty organized. They're in this order, Movies/MovieName/{Movie.jpg (image for the movie), Movie.mp4(video)}. I need my function to open up "Movies" and run through the MovieName file and post each of the contents inside those files. So kinda like a streaming service, I do NOT want to download the url file permanently on the localfile. So kinda think of netflix where they have the image of the movie, with a little description, reviews, etc and it'll stream. You can never download the movie permanently.
"What have I tried?":
I've tried using the firebase link here to guide me but it seems like I'm not understanding it. I've also tried the "list all" list all link but I don't believe it shows the data of each file. Nor was it working for me. Finally I've tried using the URLSession.streamtask()
but I've never used that before and so I'll try to successfully use it now by researching more.
"Some code":
func getAlbums() {
storageref.downloadURL { (url, error) in
if let error = error {
print(error.localizedDescription)
}
else {
//get download url
}
}
According to the firebase link attached this is what I need to do but I don't know how to get the download URL after the else statement.

How to get last picture taken by user/camera

How do I get last picture from gallery (camera roll) using flutter?
I would like to display this photo as a thumbnail like this:
I know that it's possible in android Get uri of picture taken by camera and in IOS Swift - how to get last taken 3 photos from photo library?
Is there a tool, lib, media API that could help me with that?
You can try using this library. photo_manager
List<AssetEntity> assets = [];
_fetchAssets() async {
final albums = await PhotoManager.getAssetPathList(type: RequestType.all);
final recentAlbum = albums.first;
final recentAssets = await recentAlbum.getAssetListRange(
start: 0, // start at index 0
end: 1, // end at a very big index (to get all the assets)
);
print(recentAssets);
setState(() => assets = recentAssets);
}
Use platform channels ,, as you know it's native solution
https://medium.com/flutter-io/flutter-platform-channels-ce7f540a104e
https://flutter.io/docs/development/platform-integration/platform-channels
If you're willing to do this through a dialog, you can use the image picker plugin which allows you to go through the camera's image gallery and the user can select the image (including the last image).
If you want this done completely programmatically, someone implemented a pull request for this very feature here: https://github.com/flutter/plugins/pull/676, but it hasn't been accepted because it needs some tests. You could copy the code from that PR, or add some tests, and then get it accepted into the repo!

How to set path to picture in folder in device in android appcelerator app

So I have app where I want to let users to share screenshot of score to facebook etc... I'm using SocialShare widget. In documentation it says to set path to image like this: "image:fileToShare.nativePath", but I'm not really sure how to set it. Another problem is that I need to share picture that has always different name, it saves screenshots with names like tia7828157.png,tia107997596.png... in folder in device internal memory in pictures/enigmania/ I'm new to appcelerator, so I dont know if there is something like wildcard I could use for this? Thanks for any help.
This is my code so far which I know is wrong, I know the widget works because it shares text without problem:
function shareTextWidget(e){
// share text status
var socialWidget=Alloy.createWidget('com.alcoapps.socialshare');
socialWidget.share({status:"Enigmania kvíz",androidDialogTitle:"hoho",image:test.png/pictures/enigmania});
}
You should use Ti.Filesystem class methods/properties to get the path of any file located on internal or external storage.
Also aware of the permissions of reading storage on Android 6+. Use Storage Permissions before accessing any file on Android 6+.
Simple code snippet to create a directory on internal storage at this location: pictures/enigmania and then write an image file of captured view in this directory.
function shareTextWidget(e){
var directory = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'pictures/enigmania');
!directory.exists() && directory.createDirectory();
var fileToShare = Ti.Filesystem.getFile(directory.resolve(), 'screen.jpg');
fileToShare.write($.SCREENSHOT_VIEW.toImage()); // write the blob image to created file
var socialWidget=Alloy.createWidget('com.alcoapps.socialshare');
socialWidget.share({status:"Enigmania kvíz",androidDialogTitle:"hoho",image:fileToShare.nativePath});
}
This code should work without any issues.
Note that $.SCREENSHOT_VIEW is the View ID for which you will take screenshot, so it depends on you how you maintain your View positions in order to capture correct screenshot, but point is to use Ti.UI.View toImage() method to capture the screenshot of particular view.
Let me know if this works for you or not, else we can look into other methods by getting your exact requirements. Good Luck!!!!

How to move/copy a file from one one location to the other using phonegap

I am using the Phonegap File API but am having trouble copying a file from one location to the other.
my targeted device is iOS(ipad)
my iOS version is 9.2.1
I am working on windows platform
I am using phonegap build
my requirement :
I am capturing a video and its getting saved in some temp folder by default here is the location where its getting saved (/private/var/mobile/Containers/Data/Application/2183897E-3660-4145-A822-76F5B763E48D/tmp/capture-T0x17e7cae0.tmp.avqBi2/capturedvideo.MOV)
So I just want to move this (capturedvideo.MOV) video to photo album location in my ipad
This is my code which i am trying to make it work.
function success(entry) {
console.log("New Path: " + entry.fullPath);
}
function fail(error) {
alert(error.code);
}
function moveDir(entry) {
var parent = document.getElementById('parent').value,
parentName = parent.substring(parent.lastIndexOf('/')+1),
newName = document.getElementById('newName').value,
parentEntry = new DirectoryEntry(parentName, parent);
// move the directory to a new directory and rename it
entry.moveTo(saveToPhotoAlbum, newName, success, fail);
}
Any help or working examples would be great.
Thanks
Nik`
This is simply not possible on iOS, because Apple does not allow to move videos, images or any other files out of the app sandbox to other folders. The reason that the standard-camera on the iPad/iPhone is able to place pictures there is simply because this is a built-in feature that has special permissions which your third-party app will not be able to get.
This is of course only true as long as the device is not jailbroken.
For more infos, especially concerning the file-system layout and what you are allowed to store, you should take a look at the cordova-file-plugin Readme on Github:https://github.com/apache/cordova-plugin-file

Xamarin iOS swap image in bundle at runtime

I want to allow my app to download images from the web to be placed in /images and then displayed in the UI - this is to allow branding specific images to be downloaded for a multitenant app.
The app downloads the image fine and places the image into the /Images folder
However when trying to load the image using UIImage.FromFile it always returns null - even though I know full well the image is there!
I know UIImage.FromBundle caches stuff so I chose to use FromFile but this doesn't seem to work?!
Is there something I need to do to make this work? Or am I pushing my luck a little?
I am using the following to create the file path:
public static UIImage SafeClaim_Logo = UIImage.FromFile(NSBundle.MainBundle.BundlePath +"/Images/Logo.png");
The following is the code I use to download and save the file - the file path from the above is the same below when I inspect it
HttpClient client = new HttpClient ();
var clientResponse = await client.GetByteArrayAsync(url);
using (FileStream fs = new FileStream(NSBundle.MainBundle.BundlePath + path, FileMode.OpenOrCreate))
{
var bytes = clientResponse;
fs.Write(bytes, 0, bytes.Length);
}
The app bundle is read-only so you can't change or add something in there at runtime.
All content created at runtime should be stored in your documents or cache folders.
You can get the documents folder by calling:
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
One good place to store this kind of files is the Library/ folder. On iOS 7 you can access it using:
var libraryFolderPath = Path.GetFullPath(
Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.MyDocuments), "..", "Library"));
On iOS 8:
var url = NSFileManager.DefaultManager.GetUrls (
NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User) [0];
var libraryFolderPath = url.Path;
The reason is explained by Xamarin documentation:
The Library directory is a good place to store files that are not
created directly by the user, such as databases or other
application-generated files. The contents of this directory are never
exposed to the user via iTunes.
You can create your own subdirectories in Library; however, there are
already some system-created directories here that you should be aware
of, including Preferences and Caches.
The contents of this directory (except for the Caches subdirectory)
are backed up by iTunes. Custom directories that you create in Library
will be backed up.
If you need to enable iTunes file sharing and expose the content of the Documents/ folder, your files are not visible to the user.

Resources