FFImageLoading show image after downloaded - xamarin.forms

I have offline first mobile chat app where chat messages can be also images.
I.e if I have 20 images, I want to download them first from URL and then to display them from the local files. In the meantime, I want to display a loading placeholder until the image is downloaded. Is there some best practice for doing this? Thanks!
UPDATE: I don't know when the image is downloaded because it will be processed in a queue and file location will be updated in local DB, so I can't await on that download process.

FFImageLoading has a LoadingPlaceholder property for your Images that supports UriImageSource, FileImageSource and StreamImageSource
For more information and examples, check the docs

Related

Download all images of PWA into cache from firebase storage

There is a PWA based on vuejs, which is connected to firebase.
The app has several pages with images. Each page has several images – to see all images on the page you need to scroll down the page. All images are stored on firebase storage.
When you scroll down the page at the first moment images are not displayed because the app downloads them. After a few seconds images appear.
The task is to avoid the downloading of the images during scroll down the page and display the images immediately during the scroll.
At this moment:
all images are uploaded to the firebase storage with the following metadata: metadata = { cacheControl: 'public, max-age=300000000, s-maxage=300000000' }
when the image is downloaded it appears in the app cache. When you scroll down all pages – all images are in the app cache. In this case all images are displayed immediately during the scroll.
When you refresh the page - all images are deleted from the cache.
To resolve the task my suggestion is to download all images into cache when you open PWA. And it is desirable to download images into cache for the next 3 days.
Please, help me find the way to download all images into cache for the next 3 days at the point you open the PWA.
Or if my suggestion is not the best way to resolve the task – please, advice better way to solve the task.
Thank you!
It would be nice if you could share some code with us. Especially how your Service Worker (SW) is working.
There are multiple points you should consider:
Every SW has a lifecycle and some of them are set to clear the cache on the Lifescyle event "Activated". Check if yours is doing that.
One thing you should do is catch all GET request to the images and return them from cache if they are there and from server if not (this should be done in the SW)
You can store thenm in the SW while he is getting installed. Just make sure not to save to much at once because the installation could faill very easy then.
Try to save them in smaller batches to the cache as you scroll down in advance and in a async way. You can save data to the cache also from the front end code.

Micrstrategy dont see picture in developer

In Microstrategy 10.9 I need to insert pictures as header and footer of a document. I can reach pictures with browser (stored in TomCat and IntelligenceServer folders), but cann't from Developer. I get red x. Even on preview I get - Image not Found
To see the image in Developer (the old Desktop) you should copy the images in the local installation folder of MicroStrategy or in the iServer images\ folder. More information can be found here.
You don't see the image in Developer because you are trying to reach a folder protected by the MicroStrategy authentication, but the url request is coming from your local machine which doesn't have an authenticated session.
Can you confirm that you're trying from a browser that is on the same machine as the Developer, and using the same address for the image ?
Can you check if the image is displayed correctly when the document is seen from a browser ?

asp.net application - View uploaded file instead of downloading

We have a asp.net application which allows users to upload files.
After the file has been uploaded, users get an option to download the file to view it.
We wish to also give a preview link. Clicking this link should open the file in the browser pop-up (Chrome and Firefox).
Users typically upload pdf, common image formats and word documents.
Any help would be really appreciated.
Thank You
Yash
Based on your requirement, I think you can use Google Docs Viewer.
Sample can be found over here
For more information this is the link of google blog explaining Google Docs Viewer.

not getting images displayed after uploading asp.net application

hai,
i am getting the images in my localhost.But when i am uploading my project the images are not displayed.
I am saving my images in "~/App_Themes/darkOrange/images/button_line.jpg".
Is their is another method for giving image path in ASP.Net.
please help.
thank you.
Yes - check what is actually getting rendered out in the "src" attribute for the images. See if you can physically get to that file, if you cant, means the webpage cant. Have you confirmed the images have been deployed to the web server (not local - the server you uploaded to).
If not, make sure the "Build Action" for the images are set to "Content" in the properties window in Solution Explorer.
I faced a similar problem once. But, that was just a static website. Where the images were displayed in localhost but when I ftp files to the server, the images wouldn't show.
Later, I found out that it was becasue of the different case. For e.g - The image file name was "Image.JPG" and I had used "Image.jpg" in my code
Just check if this helps.

How do you show a preview image when allowing file uploads in ASP.NET?

Here is the functionality I want:
User selects an image from their machine, hits an Upload button (or better yet the following fires on the onchange event of the file input), and is able to see a preview of the image they are about to upload.
Here is the current workflow I am using, but it seems suboptimal:
I have an image control, a file input control and a submit button control. When the submit button is clicked, the codebehind handles the OnClick event and loads the image from the file input element. It then stores it into a temporary folder on the web server and sets the image control's ImageUrl to point to it.
This works, but results in me having to do a lot of janitorial duty in cleaning up these temporary images. Is there a cleaner workflow for doing this?
If you have memory to burn:
cache the image bytes in memory
set your ImageUrl to an image handler (.ashx) with some sort of cache identifier
serve the image bytes from cache
if the user cancels or leaves, discard the cached bytes
if the user accepts, write the cached bytes to their final destination
You should upload and rename the image to match some sort of ID for your current record. Then, when you upload a new file, delete any old ones first, all in the codebehind.
If you are only showing a thumbnail, you should try to use an image library to resize the image before saving. This will save on bandwidth and storage space.
I am assuming that the problem you are trying to solve is for your application to have the ability to preview the image before the user commits to that image. Your current approach has many advantages but one disadvantage is orphaned image files in a temporary directory if the user previews several images before committing or abandons the operation all together.
I've noticed several popular social networking sites using a different approach. Basically, a Java applet is used to do the preview operation on the user's local machine. The only file uploaded to the server is what the user commits to. That approach solves the problem that you are running into; however, it introduces the new problem of requiring Java to be installed on the local machine and integrated with the web browser.
you can create a small executable to delete files on* that temporary folder, and attach it to a schedule task so it will clean your temp. folder once in a while. But I don't know if you're hosting on a dedicated server or shared hosting because with shared hosting, this doesn't work
and is able to see a preview of the image they are about to upload
...
When the submit button is clicked, the codebehind handles the OnClick event and loads the image from the file input element. It then stores it into a temporary folder on the web server and sets the image control's ImageUrl to point to it.
Imagine this conversation:
Jim: I don't know if I can afford to drive my car to work today.
Bob: Why don't you just drive to work? When you pay for it, you'll know if you can afford it or not!
Jim: Awesome!
You've just uploaded the file to show them the preview of the file they're about to upload...
While this will undoubtedly work fine if your users are uploading small images over fast connections, when someone tries to upload a 3 meg JPEG over a slow connection, and then wonders why their webpage locked up from selecting a file (they didn't even press submit remember, so you've effectively locked them up 'randomly'), you may wish to re-evaluate this as a solution.
To actually display the image before it gets uploaded, you will need to use some kind of flash or silverlight object (or perhaps a java applet) which can produce a thumbnail of the local file on the user's local disk, before it gets sent to the server. As ugly as this may sound, there literally is no way to do it without some client side plugin.

Resources