public void GetUploadStatus(int versionNumber, Version.FileDescriptor.Type fileDescriptorType, Action <ApiContainer> onSuccess = null, Action <ApiContainer> onError = null) { if (!IsInitialized) { onError?.Invoke(new ApiContainer { Error = "Upload status not retrieved: file not initialized." }); } else { Version.FileDescriptor fileDescriptor = GetFileDescriptor(versionNumber, fileDescriptorType); if (fileDescriptor == null) { onError?.Invoke(new ApiContainer { Error = "Upload status not retrieved: unknown file descriptor." }); } else { UploadStatus uploadStatus = new UploadStatus(base.id, versionNumber, fileDescriptorType, "status"); uploadStatus.Fetch(onSuccess, onError); } } }
public void FinishUpload(Version.FileDescriptor.Type fileDescriptorType, List <string> multipartEtags, Action <ApiContainer> onSuccess, Action <ApiContainer> onError) { if (!IsInitialized) { onError?.Invoke(new ApiContainer { Error = "Unable to finish upload of file: file not initialized." }); } else { int latestVersionNumber = GetLatestVersionNumber(); Version.FileDescriptor fileDescriptor = GetFileDescriptor(latestVersionNumber, fileDescriptorType); if (fileDescriptor == null) { onError?.Invoke(new ApiContainer { Error = "Version record doesn't exist" }); } else { UploadStatus uploadStatus = new UploadStatus(base.id, latestVersionNumber, fileDescriptorType, "finish"); uploadStatus.etags = multipartEtags; UploadStatus uploadStatus2 = uploadStatus; uploadStatus2.Put(onSuccess, onError); } } }
public void StartMultipartUpload(Version.FileDescriptor.Type fileDescriptorType, int partNumber, Action <ApiContainer> onSuccess, Action <ApiContainer> onError) { if (!IsInitialized) { onError?.Invoke(new ApiContainer { Error = "Unable to upload file: file not initialized." }); } else { int latestVersionNumber = GetLatestVersionNumber(); Version.FileDescriptor fileDescriptor = GetFileDescriptor(latestVersionNumber, fileDescriptorType); if (fileDescriptor == null) { onError?.Invoke(new ApiContainer { Error = "Version record doesn't exist" }); } else { UploadStatus uploadStatus = new UploadStatus(base.id, latestVersionNumber, fileDescriptorType, "start"); ApiDictContainer apiDictContainer = new ApiDictContainer("url"); apiDictContainer.OnSuccess = onSuccess; apiDictContainer.OnError = onError; ApiDictContainer responseContainer = apiDictContainer; API.SendPutRequest(uploadStatus.Endpoint + "?partNumber=" + partNumber, responseContainer); } } }
public string GetFileApiURL(int versionNumber, Version.FileDescriptor.Type type) { Version version = GetVersion(versionNumber); if (version == null) { return(string.Empty); } return(API.GetApiUrl() + "file/" + base.id + "/" + versionNumber + "/" + type.ToString()); }
public Version.FileDescriptor GetFileDescriptor(int versionNumber, Version.FileDescriptor.Type fileDescriptorType) { return(GetVersion(versionNumber)?.GetFileDescriptor(fileDescriptorType)); }
public UploadStatus(string id, int version, Version.FileDescriptor.Type descriptor, string action) : base("file/" + id + "/" + version.ToString() + "/" + descriptor.ToString() + "/" + action) { base.id = null; }