Click or drag to resize

Example 4: Upload a file

Upload a file to workspace

This example shows how to upload a document to a workspace. The UploadManager uses UploadDocumentToRoom method to upload a file to a specific workspace. This method returns uploadResult which contains a detailed information about the uploaded file.

C#
// Get an instance of UploadManager
UploadManager uploadManager = apiSession.GetUploadManager();

// Create a new SubmitDocumentsVdrJson JSON
SubmitDocumentsVdrJson uploadInfo = new SubmitDocumentsVdrJson
{
    OpenForAllRoom = false,
    Recipients = new RoomRecipientsJson
    {
        Groups = groups,
        Domains = domains,
    },
    Folder = folder,
    TagValueList = null,
    DeviceType = DeviceType.SYNC
};

// A call to the UploadDocumentToRoom
UploadResult uploadResult = uploadManager.UploadDocumentToRoom(uploadInfo,
    roomId, destinationFileName, filename, null);
Send a file via Workspaces

This example is parallel to the preceding one, but applies to the Workspaces Exchange, the UploadManager uses UploadDocument method to upload a document to the exchange and send a link to it to email recipients. This method also returns uploadResult which contains a detailed information about the uploaded file.

C#
// Get an instance of UploadManager
UploadManager uploadManager = apiSession.GetUploadManager();

// Create a new SubmitDocumentSdsJson JSON
SubmitDocumentSdsJson uploadInfo = new SubmitDocumentSdsJson
{
    // A call to generate a guid for the document and assign it to DocumentGuids
    DocumentGuids = new HashSet<string> { uploadManager.GetNewGuidForDocument()
    },
    // Create a new permission JSON
    Permission = new PermissionFromUserJson
    {
        Copy = true,
        Download = true,
        DownloadOriginal = false,
        ExpirationDate = DateTime.Now
    },
    UserRecipients = userRecipients,
    ActiveDirectoryGroupsRecipients = ADGroupsRecipients,
    ListRecipients = listRecipients,
    WhoCanView = WhoCanView.RECEIPIENTS_ONLY
};
// A call to the UploadDocument
UploadResult uploadResult =
    uploadManager.UploadDocument(uploadInfo, localPath, null, filename, null);