cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you an educator? Well we want to hear from you, so check out some tools we think might help you out here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to display an image from Dropbox folder to MVC razor view

How to display an image from Dropbox folder to MVC razor view

ArjitKapoor
New member | Level 2
I am trying to access the Dropbox API and would like to display an image hosted on my dropbox server to display on my razor view

My Controller Action:

public ActionResult ThreatsOverviewView() {
        Models.ThreatsOverviewModel tom = new Models.ThreatsOverviewModel();
        List<SelectListItem> imgName = tom.ImageName;
        string accesstkn = 
                ConfigurationManager.AppSettings["DropboxAccessToken"];                tom.dbxuser = new DropboxClient(accesstkn);                tom.dbxuser.Files.GetThumbnailAsync("RootCauses.png");    
                //Task task  = ListRootFolder(dbxuser);
                return View(tom);
            }

How to display the image in the razor view?

1 Reply 1

Re: How to display an image from Dropbox folder to MVC razor view

Greg-DB
Dropboxer

[Cross-linking for reference: https://stackoverflow.com/questions/52523055/how-to-display-an-image-from-dropbox-to-mvc-razor-view ]

Using the GetThumbnailAsync method is the right way to get the thumbnail data for an image file. That works the same way as the DownloadAsync method, for which there is an example here:

https://github.com/dropbox/dropbox-sdk-dotnet/blob/master/dropbox-sdk-dotnet/Examples/SimpleTest/Pro...

What you do with the thumbnail data is up to you, depending on what you want your app to do exactly, and how. For example, you may need to save it to the local filesystem to be read later, or you may need to return it directly to some other part of your app.

Also, "RootCauses.png" wouldn't be a valid path. File paths should start with a "/", so it would be something like "/RootCauses.png" or  "/FolderName/RootCauses.png", etc. You can also get the path from a file metadata object, using the Metadata.PathLower property.

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?