ASP.NET Web API - Handling media file authorization - asp.net-mvc

I have a mobile app with talks to backed api implemented in asp.net web api. User can post pictures from app, which I am saving in my content directory. Now user can also request the same url from app and its served to user directly from IIS.
What i want to make sure is only user who uploaded the picture should be able to fetch it. Any other user should receive 404.
Is there a way I can handle this using web api? I dont want to read file in controller and serve as base64 because this is not efficient way. I want to continue serve picture from content directory via IIS and apply authorization on top of it.
has anyone came across this problem?

Related

ios app dynamically loads data from website made on opencart

I have a website made on opencart and now I want an ios app for my website which dynamically loads data from the website. their database should be integrated so that when a change is made to any one of them it should make changes on both website and application.
Does someone provide me that API??
I dont think there is an API like you wish. You have to develop an API gateway as a middleware between your mobile apps and OpenCart backend. And I think it’s a simple job since all your data already exists in OpenCart database.

Authenticating WebAPI call using AAD

Recently we migrated our website to AAD. Website is working fine after AAD migration. But the issue is, we are generating one word document and that document contains hyperlink (web api call to generate the another attachment dynamically) to open another attachment.
We are unable to validate that request because web api call from word application.
Is ther any way to acheive this functionality.
Did you want to generate the another attachment dynamically which require authentication after users click the hyperlink in the document.
How did you want to authenticate the dynamically? Based on my understanding, if the web API also protect bu Azure AD using the Authentication / Authorization, we can enable to redirect the unauthenticated request to Azure AD like figure below:

Architecture for mobile video uploads

I have an mobile application (native iOS) and I want to provide the user the ability to upload videos and associate them to their account.
Some considerations:
I have a Node.js API running on Heroku that I use to maintain the DB.
Videos on will be stored on S3
I am looking for some suggestions on how to architect this. Here is my sequence of events I am thinking...
The app POSTs to the API to create the "event" and receives back an S3 path
The mobile app uploads the video to the S3 path it received in step 1 response.
Upon successful upload the mobile app makes a PUT to update the API that the upload was successful.
I am curious how others have approached this problem.
Your example will work fine.
You can probably get rid of the first POST request to the API and offload the responsibility of dealing with S3 to your client app.
The opposite can also work -- you can have the API deal with uploading, so that you upload your file to the API and then it will store it in S3. This could be beneficial in situations where you have multiple client apps on different platforms and you want to offload all that work to the API instead of each client having to implement it.

Send requests to a website from an iOS app

I was wondering if there's a way to send requests to a website, directly from an iOS app, for example, I type my username and password in two inputbox and then I just tap a "login" button on the iPhone, sending the credentials to a website. Can it be done?
You can send requests to a website from an iOS application. You're probably looking to perform a HTTP action.
There is a great guide by the Spring development team which guides you through the process of using RESTful services on iOS, this includes Posting data to a web service.
RESTful services also allow you the create, retrieve, update and delete data from a webservice too using a variety of HTTP calls.

Connecting ASP.NET MVC webApp and window mobile/windows phone7 app

last year I made really simple blog system. it allows user to authorize, posting, commenting. Now I want to create windows mobile/wp7 application that can adding new posts to my blog. But I have no idea how should it work. Should my web app share some api for this or my phone app should just sending specified request to server? I'm interessting how do facebook phone apps work? How they pass data to fb etc.
It would be great if anyone knows book, tutorial or something about connecting web app and phone app. I rather need app architecture tutorials than codes.
PS I know I can just open phone browser and login on website but I want to do it for fun :)
One way of approaching this is create a few actions in your controllers to return data in a format that is friendly to a WP7 app, for example, return JSON rather than HTML.
In your WP7 app you will make HTTP requests to these actions and receive the data in JSON format. From there it's up to you to handle that information on the phone.
What is the back-end of the blog system? Almost any DB data can now be exposed out as an OData Service that can be consumed on a Windows Phone app & also provide CRUD operations. Is OData a possibility?
Check out these two posts for details:
http://www.silverlightshow.net/items/Producing-and-Consuming-OData-in-a-Silverlight-and-Windows-Phone-7-application.aspx
http://www.silverlightshow.net/items/Connecting-Azure-Windows-Phone-through-OData.aspx
The second one does talk about how a central data store can be shared between web & mobile apps.
Hope this helps!

Resources