I have a bitmap or lets call it a file that I want to upload to my c# server, this bitmap (file) is captured via camera and saved into the sd card, but I have to no idea how exactly should I send it to my c# server. I don't know exactly what should I send in my request and what should be my server function's parameter to receive the file. Any help would be appreciated.
I've found this which shows how to send a file to server but it's using a php server side coding so I couldn't completely understand the process.
I'm not asking for code or anything, just a direction or explanation so I understand the concept. Thanks in advance
You need to do the following
Create a api call that will accept the file and store that file somewhere on the server.
You need to upload the image to the server with the help of the api call by passing the image file in it
Uploading image to server example
How do I send a file in Android from a mobile device to server using http?
Refer this for uploading with progress bar
Doesn't need to upload the images, just convert Image into Base64 an then upload this string to the specific field.
You can easily upload and retrieve images.
Before pushing it to server, convert your bitmap to string and push it using api. and the db field should be BLOB.after uploading the string should be converted back to bitmap and then image(This conversion should be written by api guy).
public String BitMapToString(Bitmap bitmap) {
ByteArrayOutputStream baos=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
byte [] b=baos.toByteArray();
String temp=Base64.encodeToString(b, Base64.DEFAULT);
return temp;
}
Related
I am using .NET Core 3.0 MVC app with a file upload for users. These files assumed to be an image, but for obvious reasons, I validate the image before saving it to the server.
Now I have ran into an issue, when a user tries to upload a JPEG image (which seems to be fine as he had to email it to me for further inspection) and this image seems to be a WebP image or was converted from a WebP Image.
The issue is that one of the check for each image is
using (var bitmap = new Bitmap(postedFile.OpenReadStream()))
{
}
This threw an exception "Parameter is not valid" and because of this, validation fails.
If I read the buffer of the uploaded IFromFile, it starts with RIFFÚ¶\0\0WEBPVP8
This is how I knew, this is not a normal image.
Any way to decode or validate this image as any other?
How to load Dicom image from server (path contains https://)
Am using fo-Diocm library.
var image = new DicomImage(filePath);
if filePath is from local directory its working fine.
if filePath is from server (like https://example.com/filepath.dcm), its throwing 'Dicom.DicomFileException' saying that specified path value is not correct.
What is the right way to load DicomImage from server ??
AFAIK: Not at all. Obtaining DICOM Files through Web API is referred to as WADO (Web Access to DICOM Objects), and there is an open feature request in fo-dicom to support this, but it has been assigned quite a high priority.
However, the URL https://example.com/filepath.dcm does not adhere to WADO encoding, so maybe you cannot use a DICOM communication protocol to obtain the image (or you do not want to). But in this case, your task is simply "downloading a file from an URL" and not related to DICOM at all. After the download is completed, you have it stored locally, and can go on with local file access as you are used to.
The "missing link": How to download a file from an URL
I want to create an application where the user after authentication can upload a file(txt/xml etc.) using the Azure Mobile Services and after that he can download only those files which were uploaded by himself.
I've watched a lot of tutorials (including this one: link ) but in this case they simply inserts a row to a database table. I want basically the same thing, just with files. How can I do that?
I'm really new to this, so I'm just guessing, but should I upload the files to Blob Storage, and store a link in the database pointing to that file? I'm searching for the best practice.
Yes, you are correct!
You would be limited in size if you tried to store the text file as a field in the database.
http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-dotnet-upload-data-blob-storage/
Shows how to do what you want to do but with images.
You would want to change the image stream to a text stream here:
// Get the new image as a stream.
using (var fileStream = await media.OpenStreamForReadAsync())
{
...
}
And use the Stream classes instead to open the file stream:
http://msdn.microsoft.com/en-us/library/windows/apps/system.io.stream(v=vs.105).aspx
I have a web service that sends image byte data (.jpg) to an iOS device. The iOS device saves that data to the .jpg that it is, and once it's saved to the local file system, the file cannot be opened due to a "corrupt file" message we get when trying to open it on the iOS device. The specifics of this message are irrelevant.
I am a .NET developer developing the web service. I don't know anything about Objective C - we have another developer handling that.
QUESTION: What I need to know is if the iOS device expects the byte data to be encoded a certain way, whether it has to be a Base64 string, etc. I'm not sure what the convention is for sending a file via byte data over to an iOS device. Any help would be appreciated.
Been there, but on the iOS end.
What we did to solve this problem was to have the .NET server send the image as a base64 encoded string, just as you said.
In the iOS end, the dev must then use a base64 decoding class (there are plenty on the internet, this one for example: http://www.imthi.com/wp-content/uploads/2010/08/base64.zip), transform that into NSData and then create the image with that data.
Should look something like this:
NSString *b64string = #"string to decode";
NSData *imgData = [DecoderClass decodeBase64FromString:b64String];
UIImage *image = [UIImage imageWithData:imgData];
If the data is correct, it should work.
UIImage is a high-level class and should handle image types (jpg, png, etc) automatically, as long as the data is consistent.
I'm having an issue downloading a file. I'm running this website on my local IIS. The BaseUrl correctly has the address of my local IIS site. The moduleImgPath is a Sitecore media item: "/sitecore/shell/~/media/Racking/module-image.png". The BaseUrl has the structure "http://local-$company.com".
The code used for the download is essentiall shown below. The method errors on Image.FromStream() with a System.ArguementException - "Parameter is not valid."
Stream stream = new MemoryStream(new WebClient().DownloadData(RackingConfigHelper.BaseUrl + moduleImgPath));
Image objImage = Image.FromStream(stream);
My question essentially revolves around - can you use a WebClient this way, to download data from what essentially a local source? Or will I need to deploy this code to my test environment to test it out? If I can, do I need to worry about ports?
It looks like your image data is not a jpg (I think this is typically what is expected for Image).
You can see why the error happens on this msdn link
and you can see the docs for Image on this msdn link
I would hazard a guess you are either trying to use a non-jpg OR perhaps the jpg you have may be unusually formed.