c# - Uploading an IMG file through RestSharp -


i have code:

    request.addfile ("image_request[image]", ("picture.jpg"); 

the "image_request[image]" required specific api. "picture.jpg" in /resources/ folder , correctly works.

however, application, not have file stored locally. take picture camera app , have stored photo called img, can convert .jpg

my question is: how can upload file when not have path? have .jpg image stored in variable. restsharp asks string path second parameter in method addfile, however, stated before, not have path.

i want able

    request.addfile ("image_request[image]", (img); 

path.gettempfilename

path.gettemppath

it sounds may want write file temporary file, allow in compliance .addfile's method signature

edit

//  image instance image image; using (filestream fs = new filestream(filename, filemode.open, fileaccess.read)) {     image = image.fromstream(fs);     //  save temp file - code throws exception     image.save(path.gettempfilename()); } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -