Downloading Images From Server As Binary To Android - c#

I am currently storing images in an SQL server database having type image. i have built an android app that retrieves these images by calling on a c# web service that fetches the image from the database, encode it in Base64 and send it to the android app. in the app level, i decode it and change it to image successfully. my concern is that this call downloads the data once and not in chunks and may result in timeouts in case of multiple images. so can anyone suggest an alternative? should i store the images as physical files and not in the database and use download manager to retrieve them? any suggestions would be helpful

Related

What is the best practice for sending a file from Server to mobile client?

I am using SQL Server and ASP.Net Core WebAPI as my backend. I want to send files to the mobile app from my server.
What is the best practice for doing this?
Send the file as a byte array. The mobile app has to write the business logic to process the file based on content type and display in the app.
OR
Convert BLOB to actual file based on file's content type and share the server path to the mobile app. The mobile app can download and display the content.
Note: When to delete the actual file stored on the server is a concern here.
Which one is the best one? Any other suggestions?
Thank in Advance.
Well, first, the file should be in your database or on your filesystem, not both. If you're going to do something like query the blob from the database, write it to the filesystem, and then return a URL to that written file, don't add it to the database at all, and simply store it on the filesystem in the first place.
Second, a byte array isn't something that has to be "converted", as the name implies, it's just raw bytes. That's what the client receives from the server regardless of the source. (In other words, if you read from the file system, the client is still getting streamed raw bytes.) The mime type the server returns along with the file tells the client how to interpret the bytes.

Best method to upload and retrieve files from/to server from/to Android (client side) - Xamarin

I have a web service (WCF) that gets data from the SQL Server. Is using web service more efficient than directly interacting from Android application to the server (where the folder of the files will be uploaded and retrieved). There are parts of my app which needs to get data from SQL Server database but this one doesn't need it, just for accessing that particular folder in the server.
Is there a tutorial in Xamarin which would guide me how to do it? The file types include PNG, JPEG, EXCEL, PPT, and PDF. I found this but is in iOS platform, Download a File. This one using web service, image uploading from android application to server using c# web service and this using async, download and view a PDF file.
Am I correct that before uploading it to server, it'll need to be converted to byte array? And for viewing the files from the server to Android app, is there a way to automatically display (if there is an image) it to the app and if it's EXCEL, PPT, and PDF, will show up as a link on the app and when click will ask the user to find an app to view the following file type.
I am absolutely new to this so I'd greatly appreciate any suggestion.

easy way to show images in asp.net from ftp server?

is there any easy way to show images in asp.net page from a ftp server?
If your password is secure then follow below steps :-
You really should create an FTP account that only has access to the folder with the images on your FTP server. Do that as soon as possible.
For a better overall solution, either synchronize the images to your webserver, or write an HTTP handler that will fetch the image server-side and streams the bytes to the client as if the image was on your server. Have a look at System.Net.FtpWebRequest for the second solution.
If you have write access to disk on the web server, you could implement both parts of the solution. So if an image is fetched the first time, write it to disk before sending it to the client. The next time it's requested, simply redirect the request to the image on disk (or dynamically change the URL of the tag for that product). This way, you build a cache of the images on your web server as time passes. Of course, you need to be able to invalidate the cache in case an image is updated.
<img src="ftp://..."/>

send image via web service

I want to write one program by visual studio 2008 (C# and ASP) that has web application and windows application.
I want to get clients images in web app(upload) and store them in DB (mysql) then send these images to windows app via web service (so i new web service, not web site). But i have 2 problems:
I have 2 ways to store images in mysql, first i should have BLOB field in DB -that it takes more space-, second i should save just name of each image in DB(so have image in one folder) -in this way i don't know how get image from clients and store them in that folder-. which one? Or what other?
How (code) can i transfer image via web service(Byte[] or? ).
One of the options to transfer the image using WCF is to convert image to byte array and pass it to client. Then convert from byte[] to image on client side.
Question 1:
The images or links in DB debase is old and still unresolved. There was a microsoft white paper that came out that recommended (for SQL Server 2008, so your mileage may vary) that for images/binaries under 150k DB storage is a good compromise. If most images are over, go with links, if under, store in DB.
Question 2:
The webservice will have an http context object, so you could simply use the Response.BinaryWrite method, that takes a byte[]. You will still need to write the correct headers (for mime type etc).
For a file on disk, the simplest thing to do is use the Response.WriteFile method that takes a file path argument.
In either case, you will need to intercept this on the client and convert back to an image.

Silverlight File download from client

I have a Silverlight application that implements some basic CRUD operations on a fairly flat data set. The application loads all the data onto the client to allow for quick editing (this is a fairly small data set no more that a couple K). I would like to allow them to download the file as a CSV so they can edit the data locally.
I know i can set up a HyperLink button to a URL on my webserver and then server the data dynamically using a custom server handler. But this seems kind of roundabout to me because the all the data is already all on the Client's machine (because the Silverlight application loaded it).
So i was wondering if there was a way to prompt the user for a file download and then dynamically generate the file download stream from Silverlight?
You should look at the SaveFileDialog. It allows you to prompt the user to pick a spot to save the file, and then you have access to the file through the SaveFileDialog.OpenFile method.

Categories

Resources