Click or drag to resize
Upload Files

In order to upload files, you can pass one or more FileInfo instances to the UploadFile method of a FileCabinet instance.

In case you upload data to a basket, you do not need to pass any index data. If you are uploading to a file cabinet that is not a basket you must pass index data.

Uploading huge files

Beginning with DocuWare 6.7 there are new functions to handle the upload of large files transparently, that is, you do not need to care whether you have to use chunked upload or not. See Easy Uploading huge Files for further information on this topic.

Upload files
C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        static public Document UploadSingleFileToBasket(FileCabinet basket)
        {
            var fi = new FileInfo("file.pdf");
            Document uploadedDocument;
            if (fi.Length > 2000000)
                uploadedDocument = basket.ChunkUploadDocument(fi, 0x1000000);
            else 
                uploadedDocument = basket.UploadDocument(fi);
            return uploadedDocument;
        }

        static public Document UploadSingleFileToFileCabinet(FileCabinet fileCabinet)
        {
            var indexData = new Document()
            {
                Fields = new List<DocumentIndexField>()
                {
                    DocumentIndexField.Create("RECIPIENT", "Me"),
                    DocumentIndexField.Create("SENDER", "Airline XYZ"),
                }
            };
            var uploadedDocument = fileCabinet.UploadDocument(indexData, new FileInfo("Flug.pdf"));
            return uploadedDocument;
        }

        static public Document UploadClippedFilesToBasket(FileCabinet basket)
        {
            var uploadedDocument = basket.UploadDocument(new FileInfo("Flug.pdf"), new FileInfo("HRS.pdf"));
            return uploadedDocument;
        }

        static public Section ReplaceFileContent(Document document)
        {
            var sections = document.Sections;
            if (sections == null || sections.Count == 0)
                sections = document.GetSectionsFromSectionsRelation().Section;
            return sections[0].ChunkUploadSection(new FileInfo("Flug.pdf") );
        }

        static public Section AddFileContent(Document document)
        {
            return document.ChunkAddSection(new FileInfo("HRS.pdf"));
        }
    }
}
Upload files asynchronously
C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class ExamplesAsync
    {
        static public async Task<Document> UploadSingleFileToBasketAsync(FileCabinet basket)
        {
            Document uploadedDocument = await basket.UploadDocumentAsync(new FileInfo("Flug.pdf"));
            return uploadedDocument;
        }

        static public async Task<Document> UploadSingleFileToFileCabinetAsync(FileCabinet fileCabinet)
        {
            var indexData = new Document()
            {
                Fields = new List<DocumentIndexField>()
                {
                    DocumentIndexField.Create("RECIPIENT", "Me"),
                    DocumentIndexField.Create("SENDER", "Airline XYZ"),
                }
            };
            Document uploadedDocument = await fileCabinet.UploadDocumentAsync(indexData, new FileInfo("Flug.pdf"));
            return uploadedDocument;
        }

        static public async Task<Document> UploadClippedFilesToBasketAsync(FileCabinet basket)
        {
            Document uploadedDocument = await basket.UploadDocumentAsync(new FileInfo("Flug.pdf"), new FileInfo("HRS.pdf"));
            return uploadedDocument;
        }
    }
}
See Also