I built an app that take pictures and upload them to THe server, i'm using Apache commons FTP library to upload them.
when i'm using wifi the images are uploaded without any issues...
but when i'm using 2G mobile network to send them half of them the server recieve them as corrupted images.
i set the file type to binary file type.
is there a way to determine whether the images got corrupted or not.
In order to determine whether the images got corrupted or not, compare the images received by the server with the corresponding ones on your Android device.
In order to determine why the images got corrupted, you may run WireShark or tcpdump on the server and snoop an upload. Careful examination should reveal if the problem is
within the server software (you see the complete image in the network traces), or
in the device or the network (you see a broken image in the network traces).
You also may experiment with image sizes (in terms of bytes) and check if there is a size boundary from which on you see problems. That might give clues on where to look further
Related
A friend of mine gave me a corrupted SD card. My windows 10 cannot detect it and on android it asks to format the corrupted SD card. Is there a way to partially or, best case, fully recover the data on this card?
Kind regards
Kurt
First thing you need to determine is if it's detected with correct capacity in disk management:
This is what to look for in Disk Management
If not then this is probably not DIY-able. A data recovery lab still could get the data by scraping off the back layer and soldering wires to a special reader.
If it is detected, my advise would be to create a sector by sector image file. Then, any decent file recovery software should be able to scan that image file as if it were a regular drive and recover the data.
To create such an image in Windows you could use Win32 Disk Imager, in Linux ddrescue. Any decent file recovery tool would allow you to create a drive image too.
I'll mention DMDE as an example as it is also a very good tool to analyze the image file with and recovers upto 4000 files for free (as long as they're in the same folder).
Can you please suggest me the efficient encoding technique to transfer image from iphone/android to server.
base64 encoding is too easy but i've heard it is not recommended because it increases the size of original image upto 37%
Should I use base64 encoding,, UTF-8 encoding or read and write streams to send image to server?
i want to use it in image sharing application which is client server app, and client will upload their images to server.
Can you also tell me other possible techniques just for knowledge? and which one to use?
When it comes to phones especially Android streaming will be your best choice.
It's not matter what format you will choose base64 or UTF-8, eventually a stream will be opened in behind the scene.
The only thing that matters is RAM space consume by your application, if your client will try to encode it by him self before sending it, you will use more memory and some of the devices will run out of memory, this is much more impotent then the time it takes to upload the image to the server or the disc space used by server.
So my advice is: Do not manipulate the image, just stream it as-is, with the most common system tool your client can find.
I am generating a set of images on server. I need to encode and stream these real time to a android mobile, what is the best way possible, best encoder server side to do this?
Well, you can just have picutres stored in any format and just download them into device one by one. Only matters are how fast connection do you have, how many pictures do you want to send and how fast whole operation has to be finished.
Images downloaded from server in that way are stored in inputstream, which can be saved into file or used to create Bitmap with BitmapFactory and displayed within application. Be aware of OutOfMemoryError, which occurs while creating big resolution Bitmaps with BitmapFactory, as heap is shared amog all applications and is limited to 16 MB.
As for downloading process you can do that with HttpClient library available in Android.
Having a design discussion with some co-workers about our app. Looking for the best way to transfer large data files on a, say, weekly basis from a phone to a remote server. Server will
be in the DMZ and phone will either be in WiFi mode or GSM. Some of the files will be 100Mb can even get up to 400Mb. Just not sure of the best way to approach this in my Android code. I was looking at
MTOM or even just pure FTP. Any advice would be appreciated.
I have investiagated about the use of MTOM under Android but I found nothing. I don't know whether there's any implementation working with Android yet.
But this is something you can do by FTP, which would be a good choice I think. And you could check the integrity of the file using a checksum (calculated on both sides and then compared).
Using 3G for huge files is likely to take long and to be expensive, so to me the best is to use WiFi. You can detect whether your device is connected thru WiFi as described here.
I am trying to display an image sent over a local network to my android device. An image is sent from a computer via tcp to my android device. The image is a png. The data sent over is a byte array stream of the png, which is packaged into a google protobuf message. On the android side, when receiving the data, it is read into a byte array, and the array is then given to BitmapFactory.decodeByteArray(). However, this returns null roughly 90% of the time. This only happens on a real device, but I can only test on the htc incredible at the moment. I've tried this on the android sdk emulator and i can get my image 100% of the time.
Other issues relating to BitmapFactory online has always been related to using file streams, where decoding isn't getting the entirety of the data, but I have yet to find any solutions for when the developer is sure the entirety of the data is received, and it only happens on a real device.
Is there some type of usage that I am unaware of for decodeByteArray()? The byte[] I am passing in is just the file itself.
Edit: Resolved thanks to a second insight from Brian Cooley.
I was just too quick to judge that the error may be in decodeByteArray(). If anyone ever runs into this problem do make sure that you make sure you have the data in its entirety. I made the false assumption that my byte stream was good. So first do a quick diff of the data you're sending and receiving, and make sure you're getting what you should.
One thing you might try is writing the raw bytes to a file on the SD card and looking at it on your computer, like was suggested for this question
This would reveal whether the problem is in the file or in your code. Since you are not seeing the problem in the emulator, my guess is that it is related to downloading the data over the phone.