private void EnsureUploadStarted() { lock (lockTask) { if (uploadTask == null) { StorjApiClient client = new StorjApiClient(apiUrl); if (Size > 0) { uploadTask = client.UploadStreamedAsync(Upload, fileName, Size); } else { uploadTask = client.UploadAsync(UploadAsync, fileName); } } } }
private void PersistFileReferences() { StartCommunication(); string data = JsonConvert.SerializeObject(files.Value); StorjApiClient client = new StorjApiClient(apiUrl); try { UploadedFile cloudFile = client.UploadAsync(new MemoryStream(Encoding.ASCII.GetBytes(data)), "data.dat").Result; File.WriteAllText(dataFile.Value, string.Format("{0}|{1}", cloudFile.FileHash, cloudFile.Key)); } catch (Exception e) { } finally { EndCommunication(); } }