2021.3.21f1
Hi,
I’m having issues when I send a file to an FTP with that file in the Resources folder when I’m on Android, it’s working fine on PC.
I tried to make a PreprocessBuildWithReport
to have the file being moved when building but it does not change the issue, it can’t find the file on android.
The file is a index.php
and I’m running out of ideas, is there a way to get the proper local path folder of that file or is it something just not possible ?
The logs says its looking there on android : /storage/emulated/0/Android/data/companyandprojectname/files/index.php
and it’s not finding it.
Here the preprocess build script :
#if UNITY_EDITOR
using UnityEditor.Build;
using UnityEditor;
using System.IO;
using UnityEditor.Build.Reporting;
public class PreProcessBuild : IPreprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
public void OnPreprocessBuild(BuildReport buildReport)
{
// Do the preprocessing here
string[] fileEntries = Directory.GetFiles("Assets/Resources/index.php");
Directory.CreateDirectory("Assets/StreamingAssets/");
using (StreamWriter sw = new StreamWriter("Assets/StreamingAssets/index.php", false))
{
foreach (string filename in fileEntries)
{
sw.WriteLine(Path.GetFileNameWithoutExtension(filename));
}
}
}
}
#endif
And the part where I try to upload the file to the ftp :
#if UNITY_ANDROID
string path = "jar:file://" + Application.dataPath + "!/assets/index.php";
WWW wwwfile = new WWW(path);
while (!wwwfile.isDone) { }
string indexLocalPath = string.Format("{0}/{1}", Application.persistentDataPath, "index.php");
Debug.Log("INDEX FILE PATH IS :"+ indexLocalPath);
string indexFilePath = wemoid + "/" + "index.php";
byte[] bytes = File.ReadAllBytes(indexLocalPath);
client.UploadBytes(bytes, indexFilePath);
#endif
Thanks.