c# - How to upload a mp4 to a stream through a console application using http put requests in the cloud? -
i have cloud console application. 1 of options upload mp4 file users computer.
the file gets read filestream , sent data controller http put request.
the data controller receives said http request of streamed file, finds/creates blob store file, uploads blob using streamed file.
when open , write stream program throws exception:
415 unsupported media type.
code:
//gets record user wishes add video int recordnumber = 0; console.writeline("please enter record wish change"); recordnumber = int.parse(console.readline()); response = await client.getasync("api/samples/" + recordnumber); if (response.issuccessstatuscode) { //gets video wish upload console.writeline("please enter filename wish upload: "); string filename = console.readline(); //the path name of videos string videopath = "api/data/" + recordnumber; try { //reads file stream , sends data controller using (var stream = file.openread(filename)) { console.writeline("case 6 made using satement " + filename); // httpresponsemessage response = await // client.postasjsonasync("api/samples", stream); response = await client.putasync(videopath, new streamcontent(stream)); console.writeline("video has been writen stream" + stream + "" + videopath); response.ensuresuccessstatuscode(); console.writeline("made it!!!!"); } } catch (exception a) { console.writeline("failed write stream: " + a); } } else { console.writeline("success code unsuceesful: " + response); } break;
i have unsured media type yet still getting exception.
client.defaultrequestheaders.accept.add (new mediatypewithqualityheadervalue("application/json"));
how go fixing error?
Comments
Post a Comment