how to send file (local path) using wwwForm on iOS and Android?
Hey Peeps
We are trying to upload a file a video file on Facebook using wwwForm but i don't think i have the correct local path for the device.
here is the code we are using:
public void PostVideo(string VideoLocStr)
{
Debug.Log (VideoLocStr);
this.StartCoroutine(this.StartVideoUpload(VideoLocStr));
}
private IEnumerator StartVideoUpload(string VideoLocStr)
{
yield return new WaitForEndOfFrame();
WWW www = new WWW("file:///Users/" + VideoLocStr);
while(!www.isDone) {
yield return null;
Debug.Log("progress : "+www.progress);
}
Debug.Log("size : "+www.size);
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("file", www.bytes, "Video.MOV","multipart/form-data");
wwwForm.AddField("title", "Hello World");
wwwForm.AddField("description", "How you doing?");
FB.API("123456789/videos", HttpMethod.POST, UploadFinish, wwwForm);
}
This is the error that it spits out:
result : [BaseResult: Error=bad request, Result=System.Collections.Generic.Dictionary`2[System.String,System.Object], RawResult={"error":{"message":"There was a problem uploading your video file. Please try again.","type":"OAuthException","code":381,"error_subcode":1363021,"is_transient":false,"error_user_title":"Video Upload Problem","error_user_msg":"There was a problem uploading your video. Please try again.","fbtrace_id":"DIY4Zuvn0bO"}}, Cancelled=False] , error : bad request
can't find any information on the error searching with google or on the Facebook developer website.
Does anyone know what the correct file path should be for iOS and Android?
Thank you for your time.
Kind Regards
Hey Peeps. we are stills struggling to get this right. We are using a asset called CameraShot. and it returns a path where the video is saved, which is:
/var/mobile/Containers/Data/Application/73F271CF-5DC4-497E-845B-2B45F19AABEA/Documents/CameraShot/11-04-2016 12:36:30.mov
so why do we get the error when trying to upload the file?
Answer by subjectZero · Apr 11, 2016 at 11:16 AM
hey peeps,
finally figured it out. you must define the spaces. here is the solution:
String pathForIOS = VideoLocStr.Replace (" ","%20");
WWW form = new WWW("file:" + pathForIOS);
rock on!
Your answer
![](https://koobas.hobune.stream/wayback/20220612074426im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to send a scen to another person on Andriod and IOS 0 Answers
Facebook + Unity iOS app crash on startup 0 Answers
Unity Facebook SDK Login in using FB app rather than Safari browser 1 Answer
How to upload a video to Vimeo from within a Unity application under iOS 3 Answers
Share to facebook, twitter,etc. Ios Please help out 0 Answers