File Upload servisi nasıl kullanılır?

Rest API (POST) çağrısı yaparak servisi kullanabilirsiniz. Kullanıcı (Mersis Numaranız) ve şifrenizi Basic Authentication kullanarak header a ekleyin file parametresi ile dosyanızı gönderin. fileName parametresi ile dosya adını isterseniz gönderebilirsiniz zorunlu değil ,

Servis Adresi : https://staumanalizws.tobb.org.tr/stanaliz/fileupload

Örnek Kodlar

Node JS (request)

var fs = require("fs"); var request = require("request"); var options = { method: 'POST', url: 'https://staumanalizws.tobb.org.tr/stanaliz/fileupload', headers: {'cache-control': 'no-cache', Authorization: 'Basic xxxxxxxxxxxxxx', 'Content-type': 'multipart/form-data;' }, formData: { file: { value: 'fs.createReadStream("dosyaadi.ddd")', options: { filename: 'test.ddd', contentType: null } }, fileName: 'dosyaadi.ddd' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); });

C#(RestSharp)

var client = new RestClient("https://staumanalizws.tobb.org.tr/stanaliz/fileupload"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Authorization", "Basic xxxxxxxxxxxxx="); request.AddHeader("Content-type", "multipart/form-data;"); request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"dosyaadi.ddd\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\ndosyaadi.ddd\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody); IRestResponse response = client.Execute(request);

JAVA(UniRest)

HttpResponse response = Unirest.post("https://staumanalizws.tobb.org.tr/stanaliz/fileupload") .header("content-type", "multipart/form-data;") .header("Content-Type", "multipart/form-data") .header("Authorization", "Basic xxxxxxxxx=") .header("cache-control", "no-cache") .body("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"dosyaadi.ddd\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\ndosyaadi.ddd\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--") .asString();

PHP(Curl)

< ? if (function_exists('curl_file_create')) { // php 5.5+ $cFile = curl_file_create("./dosyaadi.ddd"); } else { // $cFile = '@' . realpath("./dosyaadi.ddd"); } $post = array('file_contents'=> $cFile,'Content-Type' => 'multipart/form-data'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://staumanalizws.tobb.org.tr/stanaliz/fileupload"); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_USERPWD, "kullanici:sifre"); curl_setopt($ch, CURLOPT_HTTPHEADER,array( "Content-Type: multipart/form-data", "cache-control: no-cache") ); $result=curl_exec ($ch); curl_close ($ch); ?>