Unable to Upload file (can create user though)

0 votes
I'm unable to upload a file but I am able to use user creation api.
 
I've tried TXT, BINARY and XML file types.
 
 
InvalidCastException: Cannot cast from source type to destination type.
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW.ExecuteMultipart (System.String name, System.String filePath, System.Collections.Generic.Dictionary`2 queryParams, System.Collections.Generic.Dictionary`2 postParams, System.Collections.Generic.Dictionary`2 signParams, System.Collections.Generic.Dictionary`2 headerParams, System.String url, System.String accept, App42CallBack callBack)
com.shephertz.app42.paas.sdk.csharp.upload.UploadService.UploadFileForUser (System.String name, System.String userName, System.String filePath, System.String fileType, System.String description, App42CallBack callBack)
SendLogView+<Send>c__IteratorC.MoveNext () (at Assets/Code/Global.cs:191)
 
 
	public SendLogView(GUISkin skin, MonoBehaviour owner)
	{

		System.IO.File.WriteAllText( System.IO.Path.Combine(Application.persistentDataPath,"log.xml"), Log.Output);
		App42Log.SetDebug(true);        //Prints output in your editor console  
		
		serviceAPI = new ServiceAPI("removed","removed");

		uploadService = serviceAPI.BuildUploadService();
		userService = serviceAPI.BuildUserService();

		owner.StartCoroutine(Send ());

	}

	IEnumerator Send()
	{

		userService.CreateUser(SystemInfo.deviceUniqueIdentifier, "password", "enquiries@oddgames.com.au", new CreateUserCallBack());   

		yield return new WaitForSeconds(5f);

		uploadService.UploadFileForUser("log.xml","1", System.IO.Path.Combine(Application.persistentDataPath,"log.xml"), UploadFileType.XML, "1", new SendCallBack(this));  

	}

 

 

asked Mar 16, 2016 in Unity by david (10 points)

1 Answer

0 votes

Ok, I got it working by decompiling your code and changing the Dictionary<string,string> in ExecuteMultiPart to DictionaryEntry instead, haven't tested on device yet though....

Usage:


	
UploadService uploadService = serviceAPI.BuildUploadService();
System.IO.File.WriteAllText( System.IO.Path.Combine(Application.persistentDataPath,"log.txt"), Log.Output);
System.IO.FileStream stream = new FileStream(System.IO.Path.Combine(Application.persistentDataPath,"log.txt"), FileMode.Open);
App42UploadTest.UploadFile(uploadService, "log.txt", stream, UploadFileType.TXT, SystemInfo.deviceUniqueIdentifier, null);  

 

Code I used:

http://forum.shephertz.com/?qa=blob&qa_blobid=10022916389333118693

answered Mar 16, 2016 by david (10 points)
Great to know that your query has been resolved, let me know if you still face any issue.

Regards,
Himanshu Sharma
My problem is only temporarily fixed, the SDK needs to be updated to reflect my fix.
Hi David,

We are looking into it, once it is done from our end will let you know.

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...