本文整理汇总了C#中UnityEngine.WWWForm.AddBinaryData方法的典型用法代码示例。如果您正苦于以下问题:C# WWWForm.AddBinaryData方法的具体用法?C# WWWForm.AddBinaryData怎么用?C# WWWForm.AddBinaryData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.WWWForm
的用法示例。
在下文中一共展示了WWWForm.AddBinaryData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadJPG
IEnumerator UploadJPG()
{
// We should only read the screen after all rendering is complete
yield return new WaitForEndOfFrame();
// Create a texture the size of the screen, RGB24 format
int width = Screen.width;
int height = Screen.height;
var tex = new Texture2D( width, height, TextureFormat.RGB24, false );
// Read screen contents into the texture
tex.ReadPixels( new Rect(0, 0, width, height), 0, 0 );
tex.Apply();
// Encode texture into PNG
byte[] bytes = tex.EncodeToPNG();
Destroy( tex );
// Create a Web Form
WWWForm form = new WWWForm();
form.AddField("frameCount", Time.frameCount.ToString());
form.AddBinaryData("fileUpload", bytes, @"C:\images\img_file.jpg", "image/jpg");
// Upload to a cgi script
WWW w = new WWW(url, form);
yield return w;
if (!string.IsNullOrEmpty(w.error)) {
print(w.error);
}
else {
print("Finished Uploading Screenshot");
}
}
示例2: sendBinaryData
// 如果想通过HTTP传递二进制流的话 可以使用 下面的方法。
public void sendBinaryData(string url, string str)
{
WWWForm wwwForm = new WWWForm();
byte[] byteStream = System.Text.Encoding.Default.GetBytes(str);
wwwForm.AddBinaryData("post", byteStream);
WWW www = new WWW(url, wwwForm);
}
示例3: ApplyShare
IEnumerator ApplyShare()
{
shareToFBPanel_anim.SetBool ("show", false);
string message = transform.parent.Find ("Message").Find ("Text").GetComponent<Text> ().text;
yield return new WaitForSeconds(.5f);
#if UNITY_EDITOR
Debug.Log ("Capture screenshot and share.");
Debug.Log ("Message: "+message);
GameObject.Find ("ResultPanel").SendMessage("ShareToFB", false);
#elif UNITY_ANDROID
var snap = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
snap.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
snap.Apply();
var screenshot = snap.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "screenshot.png");
wwwForm.AddField("message", message);
FB.API(
"/me/photos",
Facebook.HttpMethod.POST,
delegate (FBResult r) {
GameObject.Find("ResultPanel").SendMessage("ShareToFB", false);
},
wwwForm
);
#endif
}
示例4: UploadFileToDropbox
public void UploadFileToDropbox(string path)
{
var text = File.ReadAllText(path);
if (string.IsNullOrEmpty(text))
{
throw new ArgumentNullException("path", path + " is not a valid path or no file exists at the path");
}
var bytes = Encoding.UTF8.GetBytes(text);
if (bytes.Length == 0)
{
throw new ArgumentNullException("bytes", "File at " + path + " did not give a valid bytes length after encoding");
}
var data = @"
{
'path': '" + path + @"',
'mode': 'add',
'autorename': true,
'mute': false
}".Trim();
var headers = new Dictionary<string, string>(3);
headers.Add("Authorization", "Bearer ie9epjU43NcAAAAAAAATeutD8nT5PHuUU3hL7NM2QDTzZNKUpIzdUKLfF2TDErr5");
headers.Add("Content-Type", "application/octet-stream");
headers.Add("Dropbox-API-Arg", data);
var form = new WWWForm();
form.AddBinaryData("data-binary", bytes);
var www = new WWW("https://content.dropboxapi.com/2/files/upload", form.data, headers);
Debug.Log(this.ToString() + " making a POST to :" + www.url);
StartCoroutine(UploadFileToDropboxInternal(www));
}
示例5: FBLoginProcess
private IEnumerator FBLoginProcess()
{
Debug.Log("Prompt FB login");
yield return StartCoroutine(FacebookWrapper.Login());
if (!FacebookWrapper.IsLoggedIn)
{
Debug.LogError("Login failed/canceled!");
}
else
{
Debug.Log("FB connected! Testing permissions.");
FB.API("/me/permissions", HttpMethod.GET, delegate (IGraphResult response) {
if (!string.IsNullOrEmpty(response.Error))
{
Debug.LogError("Error retrieving permissions.");
}
else
{
Debug.Log ("Retrieved permissions: " + response.RawResult.ToString());
}
});
WWWForm wwwForm = new WWWForm();
wwwForm.AddField("message", "I just discovered the activity \"Monday Morning Walk\". Discover more activities at: https://choosehealthier.org/node/10374");
wwwForm.AddBinaryData("image", tex.EncodeToPNG());
//wwwForm.AddField("access_token", FB.AccessToken);
//FB.API("/me/feed", Facebook.HttpMethod.POST, OnPostSuccess, wwwForm);
FB.API("/me/photos", HttpMethod.POST, OnPostSuccess, wwwForm);
}
}
示例6: ScreenshotHappy
public IEnumerator ScreenshotHappy(int playerCount)
{
//Miro dove stanno i giocatori (trucco: con 0 fa tutto lo schermo
Vector2 imageFrom = playerCount <=1 ? new Vector2(0, 0) : new Vector2(Screen.width / 2, Screen.height / 2);
Vector2 imageTo = playerCount == 1 ? new Vector2(Screen.width / 2, Screen.height / 2) : new Vector2(Screen.width, Screen.height);
byte[] temp = GetScreenshot(CaptureMethod.RenderToTex_Synch, imageFrom, imageTo).EncodeToJPG();
byte[] report = new byte[temp.Length];
for (int i = 0; i < report.Length; i++)
{
report[i] = (byte)temp[i];
} // for
// create a form to send the data to the sever
WWWForm form = new WWWForm();
// add the necessary data to the form
form.AddBinaryData("upload_file", report, "spinder.jpg", "image/jpeg"); ;
// send the data via web
WWW www2 = new WWW("http://risingpixel.azurewebsites.net/other/apps/spinder/upload.php", form);
// wait for the post completition
while (!www2.isDone)
{
Debug.Log("I'm waiting... " + www2.uploadProgress);
yield return new WaitForEndOfFrame();
} // while
// print the server answer on the debug log
Debug.Log(www2.text);
// destroy the www
www2.Dispose();
yield return null;
taking = false;
yield return new WaitForSeconds(.2f);
}
示例7: ShareImage
public void ShareImage(Texture2D image, string imageName, string message)
{
byte[] imageContent = image.EncodeToPNG();
WWWForm www = new WWWForm ();
www.AddBinaryData ("image", imageContent, imageName);
www.AddField ("message", message);
if (FB.IsLoggedIn)
{
FB.API ("me/photos", HttpMethod.POST, CallbackShareImage, www);
}
}
示例8: GetAgeGroup
public void GetAgeGroup(string filePath)
{
string url = "https://api.idolondemand.com/1/api/sync/detectfaces/v1";
WWWForm form = new WWWForm ();
form.AddField ("apikey", "a3d67cd8-4b59-4783-84d8-dc45fedea5f4");
byte[] binaryData = File.ReadAllBytes (filePath);
form.AddBinaryData ("file", binaryData, Path.GetFileName (filePath), "text/plain");
form.AddField("additional", "true");
WWW www = new WWW(url, form);
StartCoroutine(WaitForRequest(www));
}
示例9: WWWFormRequest
protected void WWWFormRequest()
{
WWWForm form = new WWWForm ();
form.AddBinaryData ("tab.text", new byte[]{0,1,2});
if (form != null && form.headers.Count > 0) {
var headers = new Hashtable (); // add content-type
IDictionaryEnumerator formHeadersIterator = form.headers.GetEnumerator ();
while (formHeadersIterator.MoveNext())
headers.Add ((String)formHeadersIterator.Key, formHeadersIterator.Value);
}
}
示例10: CreateWWW
public override WWW CreateWWW()
{
WWWForm form = new WWWForm();
if (string.IsNullOrEmpty(httpInfo.uploadFile))
{
byte[] b = ReadFile(httpInfo.uploadFile);
FileInfo f = new FileInfo(httpInfo.uploadFile);
form.AddBinaryData(f.Name, b, f.Name);
}
WWW www = wwHttp.WWWPost(httpInfo.url, form);
httpInfo.www = www;
return www;
}
示例11: MakeFaceRequest
//Making the request
public void MakeFaceRequest(string PhotoLocation)
{
Debug.Log ("Logré llegar desde el storyTeller");
//Filling the form
WWWForm FaceForm = new WWWForm ();
FaceForm.AddField ("client_id",client_Id);
FaceForm.AddField ("app_key", app_Key);
FaceForm.AddField ("attribute", "age, gender, expressions");
FaceForm.AddBinaryData ("img", System.IO.File.ReadAllBytes(PhotoLocation), "snapshot0.jpg","multipart/Form-data");
//Preparing the answer
WWW URLConnection = new WWW (URL,FaceForm);
StartCoroutine (WaitForRequest (URLConnection, FaceForm));
}
开发者ID:AlejoJauregui,项目名称:Trabajo-de-grado-Narrador-de-historias,代码行数:15,代码来源:WebServiceConnection.cs
示例12: SendData
private static IEnumerator SendData(byte[] data)
{
// Create POST form for data
WWWForm form = new WWWForm();
form.AddBinaryData("data", data);
// Upload the form to the web server
WWW www = new WWW("http://creepingwillow.com/scores.php?submit", form);
yield return www;
if (www.text == "Success") Debug.Log("Successfully uploaded score to the server.");
else Debug.Log("Error uploading score to the server: " + www.text);
}
示例13: sendDataTest
private IEnumerator sendDataTest()
{
string URL = "データを飛ばすurl";
WWWForm form = new WWWForm ();
//受け取り側はsendDataTest.phpを参照して下さい・
form.AddField("test",message);
//受け取り側はSampleSendImage.phpを参照して下さい・
form.AddBinaryData("image",bytes,"img.png","image/png");
WWW www = new WWW (URL,form);
yield return www;
if (www.error != null)
Debug.Log (www.error);
else
Debug.Log("success!");
}
示例14: TakeScreenshot
private IEnumerator TakeScreenshot()
{
yield return new WaitForEndOfFrame();
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] screenshot = tex.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
FB.API("me/photos", HttpMethod.POST, handleResult, wwwForm);
}
示例15: Uploader
IEnumerator Uploader()
{
WWWForm form = new WWWForm();
form.AddField("action", "upload level");
form.AddField("file", "file");
form.AddBinaryData("file", LevelIO.GetBytes(level.Level), "test.cowl", "application/octet-stream");
www = new WWW(uploadUrl,form);
yield return www;
if (www.error != null)
{
Debug.LogError(www.error);
}
else
{
UploadComplete();
}
}