- Home /
Unity Android Streaming Assets Save/Recall w/ WWW class?
I have been trying to access a file that is being created in my Android app and have had no luck so far. What I am doing is taking a screenshot or a picture then sending that picture out through email with Smtp(If that's the correct term it goes by). On my PC(Not on Android) I have tested the method of capturing the photo with
Application.CaptureScreenshot(Application.dataPath + "/StreamingAssets" + "filename" + pictureNumber + ".png");
and sending that photo as an attachment in an email with
'var pathToImage = Application.dataPath + "/StreamingAssets" + "filename" + pictureNumber + ".png";
string attachmentPath = pathToImage1;
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(attachmentPath);
mail.Attachments.Add(attachment);'
And that method worked flawlessly. Send the screenshot as an attachment in an email with no problems on my computer.
The problem comes when converting that path to work with Android. I can send an email with a message, subject and body from Android no problem, but Android seems to not like emails with attachments.
I replaced the path to save and attach (from the windows path to Androids path) 'path = "jar:file://" + Application.dataPath + "!/assets/";' as stated in unity's streaming assets document. Found here: http://docs.unity3d.com/Manual/StreamingAssets.html I believe the photo will not attach to the email with this method because it's compressed in a jar format.
At the bottom of that page it states: "Note that on Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s WWW class to retrieve the file then you will need to use additional software to see inside the .jar archive and obtain the file."
So my questions are... How can I use the WWW class to retrieve the photo I have saved to the android device?
Will it allow me to reference the path after it has been retrieved so I can send it through the email?
Is there a better path to save a photo taken in an app?
Lastly, am I approaching this problem in the wrong way?
Something seems off about using the WWW class to retrieve a screenshot photo taken by an android device. I have been looking into purchasing the plugin Capture and Save in the assets store, but I fear that the problem is with the attachment not being able to retrieve the file from the path or sending an email with an attachment rather then taking the screenshot.
EDIT Linux Servers? EDIT I have an idea on getting this to work but may need some direction on where to start. I have a few VPS(Virtual Private Servers) Hosted through a website. They are Linux shells and don't have much ram or storage space but I can always buy more space if needed.
Is it possible to send the photos taken in my app for Android to my Linux servers and then run the C# code to send out the email with an attachment?
I know the code itself will run on a Windows PC and send out the attachment, and I know I will need to setup the code in Unity to connect to the server and transfer files between them.
I have pushed files to my servers through CMD and a Linux Terminal with SSH so they are still setup to use SSH to set them up for taking the data from my app.
If this seems like a better approach then messing around with plugins, could someone give me some advice?
Thanks