0

I've been trying for long time to show images that I have in Dropbox, I'm reading the files correctly, but in the view I'm not sure how to put the content of the src parameter of image . In my controller I'm getting a SearchResult and then I'm adding the results to a list of type Metadata This is the code:

Dropbox.Api.Files.SearchResult resultSearch = await client.Files.SearchAsync("/MyFiles/", ".jpg");

List<Dropbox.Api.Files.Metadata> list = new List<Dropbox.Api.Files.Metadata();

for (int i = 0; i < resultSearch.Matches.Count; i++)
{
    list.Add(resultSearch.Matches[i].Metadata);
}

Until now everything works great, even in the view the things works good, but how should I set the src parameter of the image I want to show from DropBox? This code belongs to my view:

<img src="/Dropbox/MyFiles/MyImage.jpg" style="height:133px; width:213px;" class="highlight" alt="@temp">

I made a shortcut with relevant code only, I'm not hardcoding in my view but this is how the src parameter is getting filled, am I missing something? The image is not loading...

Stanislav Machel
  • 349
  • 2
  • 20
AlexGH
  • 2,735
  • 5
  • 43
  • 76
  • so what's the problem? You have the src defined there in your example. Is it not loading the image? Generally, if the image is hosted somewhere, you need the whole URL to the hosted image – Don Cheadle Dec 06 '16 at 19:42
  • @mmcrae That's correct it's not loading the image, I've tried in many different ways and it doesn't load it :( – AlexGH Dec 06 '16 at 19:42
  • @mmcrae I think I'm failing trying to get the whole url, I'm not sure yet how to get it – AlexGH Dec 06 '16 at 19:44
  • 1
    http://stackoverflow.com/questions/22079407/how-to-load-images-using-metadata-from-the-dropbox-api?rq=1 and http://stackoverflow.com/questions/23408261/image-not-being-retrieved-from-dropbox may be helpful. Either way, sounds like a Dropbox api question mostly. You need a full URL to the hosted image. Putting `Dropbox/MyFiles/MyImage.jpg` will have the website look on the server of your application, and look for those folders/files. Is the file hosted or is it on your server where the app is running? – Don Cheadle Dec 06 '16 at 19:54
  • http://cantonbecker.com/etcetera/2014/how-to-directly-link-or-embed-dropbox-images/ – Don Cheadle Dec 06 '16 at 19:55
  • @mmcrae I will check those links immediately, the file is hosted in Dropbox not in my server side :) – AlexGH Dec 06 '16 at 20:43
  • You can use [GetTemporaryLinkAsync](https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_GetTemporaryLinkAsync_1.htm) to get a temporary, direct link to a file, such as an image. – Greg Dec 06 '16 at 20:50
  • @Greg The only thing is that it expires after 4 hours, and I would like to have my application running online all the time, if you have any suggestion let me know – AlexGH Dec 06 '16 at 20:55
  • In that case you can use [CreateSharedLinkWithSettingsAsync](https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Sharing_Routes_SharingUserRoutes_CreateSharedLinkWithSettingsAsync_1.htm) with https://www.dropbox.com/help/201 . – Greg Dec 06 '16 at 21:34

0 Answers0