private void CreateEntry(LocalContent local, string checkSum, string mime, int size, List <string> labels) { var ec = new EntryCreate(checkSum, size, mime, labels, null, local.GetPathInCloud); var entryResponse = _entriesApi.CreateEntry(_bucketData.bucketId, ec); _windowElements.WriteLog($"Created entry | path {entryResponse.Path} " + $"| hash {entryResponse.ContentHash} " + $"| size {entryResponse.ContentSize} " + $"| type {entryResponse.ContentType} "); Upload(local); }
private void Upload(LocalContent local) { var entry = _entriesApi.GetEntryByPath(_bucketData.bucketId, local.GetPathInCloud); if (entry == null) { return; } using (var memoryStream = new MemoryStream()) { using (FileStream fileStream = new FileStream(local.GetFilePath, FileMode.Open, FileAccess.ReadWrite)) { fileStream.CopyTo(memoryStream); } memoryStream.Position = 0; _contentApi.UploadContent(_bucketData.bucketId, entry.Entryid.ToString(), memoryStream); _windowElements.WriteLog($"Uploaded entry {entry.Path} {entry.Entryid} {entry.CurrentVersionid}"); } }
private void UpdateEntry(LocalContent local, string checkSum, string mime, int size, List <string> labels) { var entryForUpdate = _entriesApi.GetEntryByPath(_bucketData.bucketId, local.GetPathInCloud); if (!checkSum.Equals(entryForUpdate.ContentHash)) { var entryUpdate = new EntryUpdate(checkSum, size, mime, labels); var entryResponse = _entriesApi.UpdateEntry(_bucketData.bucketId, entryForUpdate.Entryid.ToString(), entryUpdate); _windowElements.WriteLog($"Updated entry | path {entryResponse.Path} " + $"| hash {entryResponse.ContentHash} " + $"| size {entryResponse.ContentSize} " + $"| type {entryResponse.ContentType} "); Upload(local); } else { _windowElements.WriteLog($"Skip updating | file not changed {local.GetPathInCloud}"); } }