How to upload a Image with RestSharp without using a local path.
Image exists only in a Image Variable.
All i found was with a string as path, but this is not the way i want to go. Or is it possible to get the string Path from a ImageSource? How can this be solved?
My current code:
var client = new RestClient();
var request = new RestRequest(PostImageUrl, Method.Post);
request.AddOrUpdateHeader("Content-Type", "multipart/form-data");
request.AddFile("image", bauzeichnung);
request.AlwaysMultipartFormData = true;
var response = client.Execute(request);
CodePudding user response:
It is not possible, every file is need a source. But I can suggest methods that I do not recommend.
- You can convert image to base64 string and save image as string
- You can take Url of image and show in your app. But in this case image is should be updated to network before(Url).
- You can ConvertImage to base64 and store it in your cache.
- You can convert Image to ByteArray.
None of these recommendations are correct methods!!!
The most accurate method;
You can take the image and store it in your machine(Local or Server). Then tahe the path of image and save database as Url(If you don't know the difference between url and path, you should research it). When you send image just send the url of your image.