File upload error in Unity: "The format of the uri could not be determined"

0 votes
Hi!

Following API call fails for me in unity3d4.3.2f1 when using App42_Unity3D_SDK_2.6.dll

uploadService.UploadFile("file.bin", "C:\\App42_Unity3D_SDK_2.6.dll", UploadFileType.BINARY , "my save file");

Error I get is following:

UriFormatException: Invalid URI: The format of the URI could not be determined: 1.0/upload?
System.Uri..ctor (System.String uriString, Boolean dontEscape)
System.Uri..ctor (System.String uriString)
System.Net.WebRequest.Create (System.String requestUriString)
com.shephertz.app42.paas.sdk.csharp.util.Util.MultiPartRequest (System.String fileReferenceName, System.String filePath, System.Collections.Generic.Dictionary`2 queryParams, System.Collections.Generic.Dictionary`2 postParams, System.Collections.Generic.Dictionary`2 headerParams, System.String urlPost, System.String acceptType)
com.shephertz.app42.paas.sdk.csharp.upload.UploadService.UploadFile (System.String name, System.String filePath, System.String fileType, System.String description)

Some other Upload api calls work - for example I can get list of files with uploadService.GetAllFiles();

What can be wrong?
asked Apr 16, 2014 in App42 Cloud API-BaaS by laurilauri35 (11 points)

1 Answer

+1 vote

You are using sync (non-callback) method of upload, thats why you are getting this error.

Use -

uploadService.UploadFile("file.bin", "C:\\App42_Unity3D_SDK_2.6.dll", UploadFileType.BINARY , "my save file", new UnityCallBack());

You need to use the callback versions wherever possible in the Unity SDKs as the non-callback versions aren't currently Unity safe. 

These non-callback methods will be marked as depricated.

For the usage of callback methods go to documentation page :-

http://api.shephertz.com/app42-docs/file-upload-service/?sdk=unity#upload_file

answered Apr 17, 2014 by Akshay.Mishra (179 points)
Thanx you, this helped!

However in real scenario I can't use the file version of the function, but need to use this one:
public Upload UploadFile (string name, Stream stream, string fileType, string description)
This is because unity web player can't create the file in first place.
But unlike reglar UploadFile, the stream one is not available with App42Callback argument in App42_Unity3D_SDK_2.6.dll.

Is there a plan to add this function in near future?
O.K we'll add this feature in next release, and will update you by updating this thread.
And thanx for suggestion.
This feature is now available in Unity SDK version 2.7.
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
...