Uploading Images etc Works fine in the Editor and in Windows Builds but not on android, if i upload an image from android it comes out as Empty, But if i upload from Windows or Editor, it works just fine
if (Application.isEditor)
{
Debug.Log("Here Editor");
NativeFilePicker.PickFile(ImportModel, allowedfiles);
}
else if(SystemInfo.deviceType == DeviceType.Handheld)
{
Debug.Log("Here Phone");
NativeFilePicker.PickFile(ImportModel, allowedfiles);
}
else if(SystemInfo.deviceType == DeviceType.Desktop)
{
Debug.Log("HereDesktop");
FileBrowser.ShowLoadDialog(ImportModel_Win, OnCancel, FileBrowser.PickMode.Files, false);
private void ImportModel_Win(string[] paths)
{
foreach (var item in paths)
{
Debug.Log(item);
}
ImportModel(paths[0]);
}
public void ImportModel(string thePath)
{
if (thePath == "" || thePath == null) return;
Sprite sprite = IMG2Sprite.LoadNewSprite(thePath);
if (sprite)
{
//Creat a new img
getImageUI.Success_AddAttachment(sprite);
Upload_AttachmentSuccessfully(sprite, thePath);
}
}
}
public virtual IEnumerator UploadMultipleFiles(long ticketID, string type)
{
sendingFiles = true;
UnityWebRequest[] files = new UnityWebRequest[getAllAttachmentLocalPaths.Get_Attachments.Count];
WWWForm form = new WWWForm();
UnityWebRequest req = new UnityWebRequest();
for (int i = 0; i < files.Length; i++)
{
files[i] = UnityWebRequest.Get(getAllAttachmentLocalPaths.Get_Attachments[i]);
yield return files[i].SendWebRequest();
form = new WWWForm();
form.AddField("UnityIdentifier", OnSelectedItem.Instance.CurrentIdClicked);
form.AddField("TicketId", ticketID.ToString());
form.AddField("Type", type );
form.AddField("ProjectFileId", OnServer.Instance.CurrentProjectLoaded.ProjectFileId.ToString());
form.AddBinaryData("File", files[i].downloadHandler.data, Path.GetFileName(getAllAttachmentLocalPaths.Get_Attachments[i]));
req = UnityWebRequest.Post("post IP", form);
if (AddToken() != null)
{
req.SetRequestHeader("Authorization", "Bearer " + AddToken());
}
yield return req.SendWebRequest();
}
if (req.responseCode == 200)
{
sendingFiles = false;
Debug.Log("Uploaded " + files.Length + " files Successfully");
}
else
{
Debug.Log(req.error);
}
}
Does anyone know how to fix it ?