1
Code changes for updates
Question asked by Rob Smith - 8/29/2022 at 6:00 AM
Answered

Hello,

With the most recent updates, I'm seeing that the "DocumentLocation" on class DocumentViewer has been deprecated/moved/removed/changed.

I am loading documents from AWS S3 and am not able to see how to continue to do this with the new updates.

This is my existing code to instantiate the DocumentView class:

var documentViewer = new DocumentViewer
{
Width = 800,
Height = 600,
Resizable = true,
DocumentLocation = new AmazonS3Location
{
BucketName = Settings.Default.S3EntityDocumentBucketName,
Region =,
AccessKeyId = ,
SecretAccessKey =
},
Document =
};

If someone could send me a link to instructions on how to accomplish this with the new updates, I would greatly appreciate it.

Thank you in advance.

3 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Answer
Hi,
Here is a new example code:

var documentViewer = new DocumentViewer
{
    Width = 800,
    Height = 600,
    Resizable = true,
    
    //Setting an Amazon S3 file provider via a FileSystemFileProvider instance:
    Document = new FileSystemFileProvider
    {
        File = "SomeFile.ext",
        Location = new AmazonS3Location
        {
            //Leave Path empty to connect to the root of the bucket. 
            //For connecting to subfolders, Path should be specified as a relative path (eg. "some/folder")
            //Path = "some/folder",

            BucketName = "BUCKET",
            Region = "eu-central-1",
            AccessKeyId = "XXX",
            SecretAccessKey = "XXX",
        }
    }
};

Example code for all FileProvider API is documented here:

0
Rob Smith Replied
Thank you for the response, but for some reason, I'm unable to get this working.

Essentially, it makes sense to me that you either provide the BUCKET and FILENAME, but not the PATH.  
OR
You provide the full path without the bucket name and filename.

What am I missing?

Error Message: Invalid Location string. 

Here's what I've got:

var fileName = "somefile.pdf;
            var relativePath = "sub-folder/another-sub-folder";
            var path = $"{BUCKET_NAME}/{relativePath}/{fileName}";
            var documentViewer = new DocumentViewer
            {
                Width = 800,
                Height = 600,
                Resizable = true,
                Document = new FileSystemFileProvider
                {
                    File = fileName,
                    Location = new AmazonS3Location
                    {
                        Path = path,
                        Region = "eu-central-1",
                        AccessKeyId = Settings.Default.AwsAccessKey,
                        SecretAccessKey = Settings.Default.AwsSecretAccessKey
                    }
                }
            };
0
Cem Alacayir Replied
Employee Post
This is wrong:

var path = $"{BUCKET_NAME}/{relativePath}/{fileName}";

Bucket name is specified via a separate property not inside path:

 Document = new FileSystemFileProvider
    {
        File = "SomeFile.ext",
        Location = new AmazonS3Location
        {
            //Leave Path empty to connect to the root of the bucket. 
            //For connecting to subfolders, Path should be specified as a relative path (eg. "some/folder")
            //Path = "some/folder",

            BucketName = "BUCKET",
            Region = "eu-central-1",
            AccessKeyId = "XXX",
            SecretAccessKey = "XXX",
        }

Reply to Thread