Beispiel #1
0
        public void DownloadFile(string fileId, string fileExtension)
        {
            CreateApiService createApiService = new CreateApiService();
            var request = createApiService.CallAppiService().Files.Export(fileId, "application/pdf");

            request.MediaDownloader.ProgressChanged += (IDownloadProgress progress) => {
                switch (progress.Status)
                {
                case DownloadStatus.Downloading:
                {
                    // progress.BytesDownloaded;
                    break;
                }

                case DownloadStatus.Completed:
                {
                    Console.WriteLine("Download complete.");
                    break;
                }

                case DownloadStatus.Failed:
                {
                    Console.WriteLine("Download failed.");
                    break;
                }
                }
            };
        }
Beispiel #2
0
        public void DeleteFile(string fileId)
        {
            CreateApiService createApiService = new CreateApiService();

            FilesResource.DeleteRequest request = createApiService.CallAppiService().Files.Delete(fileId);
            request.Execute();
        }
Beispiel #3
0
        private FilesResource.ListRequest ParameterizedRequest()
        {
            CreateApiService createApiService = new CreateApiService();

            FilesResource.ListRequest listRequest = createApiService.CallAppiService().Files.List();
            listRequest.PageSize = 10;
            listRequest.Fields   = "nextPageToken, files(id, name)";
            return(listRequest);
        }
Beispiel #4
0
        public File UploadFile(String title, String description, String mimeType, String filename)
        {
            // File's metadata.
            File body = new File();

            body.Name        = title;
            body.Description = description;
            body.MimeType    = mimeType;
            // File's content.
            byte[] byteArray = System.IO.File.ReadAllBytes(filename);
            System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
            try
            {
                CreateApiService createApiService       = new CreateApiService();
                FilesResource.CreateMediaUpload request = createApiService.CallAppiService().Files.Create(body, stream, mimeType);
                request.Upload();
                File file = request.ResponseBody;
                return(file);
            }
            catch (Exception e)
            {
                throw e;
            }
        }