how do you correctly copy a jpg file from streaming assets folder using www?

I have found couple of questions in these posts which are near to my problem but I see no answers. I am copying from streaming assets to a directory in an Android version. My copy method works for text files but fails for some jpg images I want to copy over.

The setup code:

 var dir_path2 = Path.Combine(Application.persistentDataPath, "saved_images");
   Directory.CreateDirectory(dir_path2);
   ReadFromStreamingAssets("saved_images/spectrum_blue");
   File.WriteAllText(Application.persistentDataPath + "/saved_images/spectrum_blue", stream_result);
   Debug.Log("stream_result for spectrum_blue:"+stream_result);

The ReadFromStreamingAssets code:

public static void ReadFromStreamingAssets(string file_ref)
    {
        var full_path = Path.Combine(Application.streamingAssetsPath, file_ref);
        Debug.Log("full_path at start of ReadFromStreamingAssets"+full_path);
        if (full_path.Contains("://") || full_path.Contains(":///"))
        {
            WWW www = new WWW(full_path);
            while (!www.isDone) { }
            stream_result = www.text.Trim();
            Debug.Log("TRIM");
        }
        else
        {
            Debug.Log("full_path:"+full_path);
            stream_result = File.ReadAllText(full_path);
        }
    }

This method works for everything but jpegs. When I run on a jpeg I get 0 length files created. I’m hoping there’s some magic line of code to replace: stream_result=www.text.Trim() because that is
exactly where the problem seems to occur. The docs say something about bytes property but I
can’t seem to hit on right combination of letters (I often think coding is partially a random walk through murky shadows). Thanks for any help!

Hello friend.

First of all, I would really prefer using Coroutine if I was you. This while looks very wild! Now… I think that your problem is that you are trying to read text while you should read bytes. I would create a default Texture2D, create it from thw WWW.bytes and save it as a .jpg image in the destination location. Maybe try doing that. Also… streaming assets in android is a big pain in the head! Try using this tool. It is free and very easy to use. Helped me a lot!!