I want to store images on a separate physical drive eg. D:\images\{UserID}\picture1.jpg (note UserID is a folder with a Guid value) and translate that to a URL on my website for example https://www.website.com/images/picture1.jpg or maybe https://www.website.com/images/{UserID}/picture1.jpg. If I click on an image, it shows the larger image. The source project may be stored on my C:\Project drive. I also want to create a grid layout of images like on YouTube. I’ve looked all over the internet for a solution but have not found what I needed. Anybody got any recommendations for this problem?
I know from my research that I’ve found many examples on the internet that show you can put an images folder in your project or have an images folder in your wwwroot folder but that’s not what I want. Lastly will there be any problems security wise with using a userID as a folder name?
Here are some code examples that I found on the internet:
https://www.codeproject.com/Questions/812675/how-to-show-an-image-in-image-control-retrived-pat
https://codereview.stackexchange.com/questions/133616/reading-and-displaying-an-image-from-a-folder
Related
i have solution where are three project (Intranet, Site, and Data). In Intranet i have form where I add new Restaurant object (name, description, photo and etc.). Photos are saved in Path Intranet/wwwroot/images/items and link to the photo is saved in database like this:
wwwroot\\images\\items\\<photo_name>
When i want display photo in this same project i use:
<img class="img-responsive" src="#Url.Content("~/images/items/" + #item.Photo2)" alt="">
But if i want display this photo in other project (Site), it doesn't work, since they are in other project. It is possible change src in Site Project to display photos from another project? Or is better way to do this?
One of the solutions might be to use a virtual folder that points to the right physical folder of the source project. This folder will act as own folder of the Site project and you can point to its content in a similar way as you do in the Intranet.
i.e. if Intranet path for images is
C:\inetpub\wwwroot\images\items
^^^^^
create a new virtual directory /items under /images of Site project in IIS and point to the same source directory of your other project
C:\inetpub\wwwroot\images\items
This will let you to access same images as ~/images/items/ in the Site project.
Another approach would be to create an image handler that will programmatically access required file and output it to the browser as an image.
I'm looking for creative ways to solve a difficult problem. And I need to do this via C# code only, no website configurations.
My users upload a "package" of files. These are usually HTML files with relative paths to images and other resources. Currently I store these in a folder in an S3 bucket. So far there is no problem.
The problem appears when I need to serve this file back to the client. I need a way to give them access to the HTML file for X amount of time while also keeping the integrity of the URL links.
For instance - File.html has a reference to fish.png -
<img src="fish.png"/>
If I grant them access to File.html the fish image is broken because they do not have access to "fish.png". If I grant them access to both the link is still broken because the src doesn't have the security token. I've even tried granting access to the folder and both files but still the image is broken. I also can't download the contents because that would defeat the purpose of only having the resource available for X amount of time.
I hope my problem is clear. I am very new at S3 development in general. Any help is appreciated.
EDIT - I wanted to add that modifying the HTML document links is not an option. They don't always upload HTML, it could be flash files or other file types. I need the document links references to be maintained.
You need to first figure out why if they have access to the entire folder, that it doesn't work.
If they have access to the folder, and both files are in that folder and the link to the image has no path, it should work. Until you get that use-case solved, getting the time-based url's working is a non-starter.
You may want to make sure the capitalization is correct - it matters in s3, whereas if you are used to running in IIS it usually doesn't.
One potential way to do this would be to make the IMAGE files public, and make the HTML files "signed urls". You can set an expiry time on the signed urls that reference the image files. The image files obviously wouldnt expire, but the access to HTML files that reference the image files WOULD expire.
Not the prettiest solution, but the problem isnt very pretty either. ;-)
You can read more about Pre-Signed URLS here: Generate a Pre-signed Object URL using AWS SDK for .NET
This might be overkill but I think it would work.
When a user requests the file, you copy the file and any files referenced in the file to a public area (perhaps in a directory using a GUID as a name so it's not easily guessable by other users).
Then when the time has expired you can simply delete the new directory.
Pretty much I must find a way to populate image boxes with the corresponding information to the images, if it's possible in a Windows 8/Metro/Store App. I have a database with all the physical paths of the images which are stored on the local computer e.g: "c:\BookImages\spud.jpg". Now when i pull the information from the database with information about the book, I also take the file path of image("c:\BookImages\spud.jpg"). All i need to now do is to fetch the image and display it in a image box. But i do not how to do this, i have been researching for a while now, and I'm coming to the understanding that i cannot select file's from other than the actual install directory of the windows app. Unless i use a FileOpenPicker, which will be a useless for the user to select the folder which contains the images every time they run the app. If anyone has a solution to my problem please let me know it will be much appreciated.
See If all the directories were given access for a win rt app then it would be a security risk
So some specific folder are available try storing user data in there . After that only File Picker can Help.
Heres the link
Folders for winrt
Its a Microsoft policy so Please design app accordingly. You might needd to set capabilities in the app manifest file for some folders. Please go through it :)
The short answer is to have the user pick the folder once and save the StorageFolder in the Windows.Storage.AccessCache.
The long answer is that all this boils down to having your data store in a place that is programmatically accessible.
One option, as Anobik pointed out, is to use either your appdata folders (where you have open access), or something like the Pictures Library, which you can access given a capability in the manifest. This way you don't need to ask the user.
If you use the file picker to let the user select a folder for the data store, he or she has granted permission to access that folder programmatically, including its contained files.
The important thing is that you have to preserve that permission across sessions, which is the purpose of the AccessCache.
Think of a StorageFolder object (and a StorageFile) as an abstraction for a pathname--you never really want to save pathname strings unless you have inherent programmatic access to that location. This isn't true for stuff from the file picker, so you have to use the AccessCache to essentially save the folder reference and its permissions.
Kraig Brockschmidt
Author, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press (also see second edition preview)
I need to show list of file from Remote Server. For this I already fetch the details of Remote server using Self Hosted Web Service. i.e. I fetch remote server file name and full path as JSON String and then show the information in TreeView [WPF]. Now I need to show the icons of these files. For this I think I Can use the icon within the client desktop application and I found 2 solution
http://www.codeproject.com/Articles/2532/Obtaining-and-managing-file-and-folder-icons-using#_rating
and
WPF's
System.Drawing.Icon.ExtractAssociatedIcon
However I love the solution from Later part but it doesn't work for given file name[i.e. file should present in system, which is not the case with me]. I try to run above code's sample, and Icon shown by it are not really very good or clean. So, Is there better way to extract/get Associated file Icon for extension in C#, WPF.
Thanks.
I search more and found the CodeProject's Article is only suggested way of extracting Icon. Though I am still experimenting it and in last 2 hours I am not able to show Icon in my Treeview though object seems filled correctly for me.
I have a little payments webApp, our customers can install it on their IIS and work with it. They can upload their own logotype.
We are using WyBuild to update this apps, but it replaces all files on the web folder with the new version, so the logotypes are deleted, that's why we placed the customer's files in program files, so the updater can't delete them.
the problem is that I can't load the images from the following path
C:\Program Files\MyApp\ImageFoder\logo.jpg
I don't know how to do it and I'm almost sure that is not possible to load
My web application is on
C:\inetpub\wwwroot\MyApp\
I can't have the images on the webFolder because wyBuild deletes them when I'm trying to update them, I already tried the paths like this: (the don't work)
///file:c:/program files/ .... etc
so, the question is
How can I load an image to an asp:image control using it's windows path ?
You need to configure an IIS Virtual Folder to point to the alternate location where the images are stored.
I wouldn't put them in Program Files, though, a sibling folder in wwwroot would be better.
Remember NTFS permissions are easy to mess up and it's easier to manage them in a single place.
Update - for locally installed, localhost-only sites Alternatively (and this is only a good idea if you have minimal amounts of traffic. NOT for public websites), you can serve files from an arbitrary location using a VirtualPathProvider. It sounds like this 'web app' is installed like a desktop app for some reason? If you want to store user data externally, the user's App Data folder would be appropriate, but ONLY if the web app refuses external connections, and can only be accessed from the machine.
Since you're dealing with images, I'd grab the imageresizing.net library and use the VirtualFolder plugin to serve the files dynamically. It's 200KB more in your project, but you get free dynamic image resizing and/or processing if you need it, and you save a few days making a VirtualPathProvider subclass work (they're a nightmare).
Wouldn't it be better to use isolated storage?
Added: I mean on the users machine, and upload them again if they are not found. This takes away your overhead completely.