Exemple #1
0
 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);
         }
     }
 }
Exemple #2
0
 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);
         }
     }
 }
Exemple #3
0
 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);
         }
     }
 }
Exemple #4
0
        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());
        }
Exemple #5
0
 public Version.FileDescriptor GetFileDescriptor(int versionNumber, Version.FileDescriptor.Type fileDescriptorType)
 {
     return(GetVersion(versionNumber)?.GetFileDescriptor(fileDescriptorType));
 }
Exemple #6
0
 public UploadStatus(string id, int version, Version.FileDescriptor.Type descriptor, string action)
     : base("file/" + id + "/" + version.ToString() + "/" + descriptor.ToString() + "/" + action)
 {
     base.id = null;
 }