Android : Universal image downloader cache path - universal-image-loader

Am using UIL to download images and i want tht images to be saved in cache only. So in configuration i have enabled cacheInMemory() options. But when i check my app info in settings its still shows 0.00B. Where exactly my images are getting stored if i enable cacheInMemory() options. ?
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.item_fine_dining).cacheInMemory().build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext()).threadPoolSize(3)
.memoryCache(new WeakMemoryCache())
.threadPriority(Thread.NORM_PRIORITY - 1)
.denyCacheImageMultipleSizesInMemory().enableLogging()
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.enableLogging().build();

Related

Adding dynamic assets to Flutter app in runtime

I have Flutter app which needs to load dynamic assets and content which I want to save for later use. I know about Assets I can have in build time at the folder "assets/" inside the app.
I want to download content using ZIP files and unzip them to app local folder so they won't delete in the next app update.
what are the folders Flutter allows me to add assets to at runtime?
You cannot dynamically add assets to Flutter app at runtime and that is why Shared_Preferences package was developed by the official Flutter_Dev Team.
https://pub.dev/packages/shared_preferences
If you want to store a File instead of bits of information then refer to the below example code (For a Image File):
Future getImage(ImageSource imageSource) async {
// using your method of getting an image
final File image = await ImagePicker.pickImage(source: imageSource);
// getting a directory path for saving
final String path = await getApplicationDocumentsDirectory().path;
// copy the file to a new path
final File newImage = await image.copy('$path/image1.png');
setState(() {
_image = newImage;
});}
If your still want to somehow add/delete files dynamically then the answer is that it is practically not possible because assets weren't designed to dynamically store files.
One should only use assets to store files which shall remain common for all users.

Customize appsetings.json for user in ASP Core 1 app

My goal is to have appsettings.json file with production configurations and have possibility to costomize it for every developer, e.g. use local connection strings. So it does not similar to transform web.config mechanism, i don't want depends on bulid configuration. Can anyone provide solution for this goal?
In one of my past project we do so: we store all configure information in custom config.xml and parsed it into the custom structure. Web.config contains only server configaration. every developer has own copy of config files with his own data. Solution is that application use configuration files from path, that specified in environment path in windows via Environment.GetEnvironmentVariable("key").
Does anyone have idea better than my one?
This is how I manage configuration: see comments in the code
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json"); // this one has default configuration
// this file name is added to my gitignore so it won't get committed,
// I keep local dev configuration there
builder.AddJsonFile("appsettings.local.overrides.json", optional: true);
if (env.IsDevelopment())
{
// This reads the configuration keys from the secret store.
// if you need a more secure place for dev configuration use usersecrets
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}
// the order in which config sources is added is important, a source added later
// will override the same settings from a source added before
// environment variables is usually for production and therefore added last to give it higher priority
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}

Is it possible to configure CKFinder as just a file browser without any upload functionality?

I want to be able to click on the image icon in CKEditor and be able to browser the local file system. I would like the chosen file to be passed to the editor just like the standard URL is. I want to use the base64image plugin to embed the image inline.
I have tried using CKFinder but, when I click the Browse Server button in the Image Properties dialog, I get an empty window with just 'run();' in the centre.
To enable CKFinder in read-only (gallery) mode, set the readOnly configuration option to true and pass it as a configruation option to the CKFinder.setupCKEditor function:
CKFinder.setupCKEditor( editor, {
readOnly: true
} );
This will disable the possibility to modify anything.
If you only want to disable uploads, you can disable modules related to upload operations:
CKFinder.setupCKEditor( editor, {
removeModules: 'FormUpload,Html5Upload,UploadFileButton'
} );
The second thing is to change Access Control settings in the server side connector by setting 'FILE_CREATE' to false so the uploads will be disabled also on the server side.

Image doesn’t load consistently from Azure blob storage

I am having an erratic problem using Azure blob storage where my images do not load consistently. The problem is that sometimes when I load a web page, the browser will not show the image, but if I refresh it will load correctly.
When the image doesn't load, the browser shows the default image placeholder. Here is an example:
If I check the hyperlink for the image placeholder, I find that it is the same as the when the image loads successfully, except the Shared Access Signature is different.
Sometimes the same image will fail to load for one link but load successfully for another link even in the same page and same page load. The only difference in the URL is the Shared Access Signature.
Here is my code to build the URL with the shared signature
// Get reference to blob (file) that is to be downloaded
blob = blobContainer.GetBlobReference(blobURL.ToString());
// Get shared access signature to download file from azure blob (valid upto "active duration" minutes) from now
signature = blob.GetSharedAccessSignature(new SharedAccessPolicy()
{
SharedAccessStartTime = null,
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60),
Permissions = SharedAccessPermissions.Read
});
// Append signature query string to blob / file that is to be downloaded
downloadURL = string.Format("{0}{1}", blob.Uri.AbsoluteUri, signature);
This is the final HTML image link on the web page, i.e. if I show source on the web page in the browser:
<img alt="Profile Picture" src="https://mystorageaccount2.blob.core.windows.net/abcdefg1-hi23-40b5-86de-a20b568f5626/1601/1234d664d1b74ce1aebf4403e5b74af7.jpg?se=2015-10-31T11%3A38%3A39Z&sr=b&sp=r&sig=SaiUToJg%5Ab3zcdef8EeOq84urHf6HQqS%2BAFt1dEQMNI%3D">
Has anyone else seen this problem? Any recommendations on what I might be doing wrong?
I suspect this could be related to the expiry period which you have set on your image blob's shared access signature (SAS). Is there any good reason where you need to set the SAS to 1 minute when you have set it's permission to read-only?

How to decode a bitmap from a local file deployed with Android application

I am going through http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/images/
and trying to get the Local Images working with Android however I am experiencing some issues when attempting to do something in normal monodroid just as a further test. I'm using a SharedProject, just for reference.
I have added the test image at Resources/drawable (test1.png), and also setting the Build Action as AndroidResource as it describes, and if I do the following in Xamarin.Forms it works:-
Xamarin.Forms.Image myimage = new Image();
myimage.Source = ImageSource.FromFile("test1.png");
However, if I try and retrieve the same file via the following it comes back as null.
Android.Graphics.Bitmap objBitmapImage = Android.Graphics.BitmapFactory.DecodeFile("test1.png")
Does anyone know why this is null and how to correct?
The Xamarin.Forms FileImageSource has a fallback mode as it covers two different scenarios.
First it will check whether the file exists in the file system via the BitmapFactory.DecodeFile.
Should the file not exist as specified in the File property, then it will use BitmapFactory.DecodeResource to try and load the resource content as a secondary alternative.
FileImageSource for Android therefore isn't only just for files that exist in the file system but also for retrieving named resources also.
This link indicates that Android Resources are compiled into the application and therefore wouldn't be part of the file system as physical files.
Since test1.png is a Drawable you should use BitmapFactory.DecodeResource ()
string scr = "#drawable/test1.png";
ImageView iv = new ImageView(context);
Bitmap bm = BitmapFactory.DecodeFile(src);
if (bm != null)
iv.SetImageBitmap(bm);

Resources