Hello there !
I have a PostExport method working perfectly well locally but which seems to silently “fail” on Cloud build.
By fail I mean that the method is correctly executed until the point it encounters an await
, then cloud build carries on with the build even if my method if not completed.
Here is the async method used in the PostExport :
private static async Task Upload(string url, string filePath, string token) {
Debug.Log("Launching upload method, url: " + url + " , filepath: " + filePath + ", token:" + token);
var fileStream = new FileStream(filePath, FileMode.Open);
try {
// We need to use a StreamContent for this to work
var streamContent = new StreamContent(fileStream);
streamContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") {
FileName = Path.GetFileName(filePath),
Name = "file"
};
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var multi = new MultipartFormDataContent {streamContent};
var response = await client.PostAsync(url, multi);
if (!response.IsSuccessStatusCode) {
Debug.Log("An error was returned from the server while uploading");
Debug.Log(JsonUtility.ToJson(response));
Debug.LogError(response.StatusCode);
} else {
Debug.Log("Asset bundle zip upload completed!");
}
} catch (Exception e) {
Debug.Log("An exception happened while uploading");
Debug.LogException(e);
throw;
} finally {
Debug.Log("Disposing of file stream (finally block)");
fileStream.Dispose();
}
}
}
The first Debug is working correctly, but I never get any other debug logs (nothing in the catch, nor in the finally block, etc).
The method is called like this :
await Upload(uploadUrl, filePath, token);
It’s working locally, and I’m pretty confident it was working until recently in cloud build.