Retrieving images in React from a protected backend folder - react-native

I'm working on a React-app in which I would like to show the avatar of the logged in user. I retrieve all the user-information from my PHP backend, so i know the url of the image i want to show. The images however, are stored in a private folder which is protected with a .htaccess file.
Because of privacy reasons, the images-folder needs to remain private, so the images can't directly be accessed. I was thinking about converting the image with base64 encoding and passing it through the api, but this doesn't feel like a correct solution. Is there a way to retrieve the images from the private folder, by authenticating myself in any kind of way?
Thanks in advance

Related

How to store and extract images

We are having an exercise on making mobile apps. Currently, we want to render each product and have their images attached. Initially, we refer to how to save images to a folder and save their path in the DB. but the problem comes when I call the API in React which gets this binding into a variable and can't use require in the Component Image. So we are thinking about converting the image to base54 and storing it. Trouble is, this string is quite large. Can someone give me advice on solving this problem, or a link to a tutorial.

phoenix: show image from aws s3

I study the phoenix, create an application that loads the image on aws s3, and then displays it. I was able to upload the image to the cloud, but now it is not clear how to display it to the user on the page (I do not want to make public link to these images in the cloud). I was looking for information on this issue, but did not find anything useful.
From the clouds I get the file as binary data. Do I need to create some of these data is a temporary file that will be displayed on the page? I can display the image as base64, but I think this is not the best way. I would appreciate advice.
Since you've already fetched the image to a binary, you can just send it directly to the client with the appropriate content type and the browser will render it as an image. For example, to fetch and send the png at https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png:
def index(conn, _params) do
image = HTTPoison.get!("https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png").body
conn
|> put_resp_header("content-type", "image/png")
|> send_resp(200, image)
end
If you open this in your browser, you'll see the image being rendered correctly because of the content-type header.

Play lock screen slideshow from local images (Windows 8)

I'm trying to play lock screen slideshow from images stored in local folder. All ways which I found didn't help me. There're four methods in LockScreen class from Windows.System.UserProfile namespace and only one allow you to play slideshow(from images which you want). It's:
public static IAsyncOperation<SetImageFeedResult> RequestSetImageFeedAsync(
Uri syndicationFeedUri
)
But 'Uri' parameter must be the external URI of the RSS image feed. That's why I can't use it. Could somebody help me, how o do this?
Actually you can use Uri for local paths. You can find more info here.

How to upload photos using CakePHP 2.0

I'm developing a simple web app and I just want to allow the user to upload some pictures.
should I just store the picture url on my database table or should I upload the whole picture?
how can I validate the size of the picture being uploaded?
how can I upload the picture from my controller?
thank you all!
I would NOT store the image data in the database. I would create a Behavior that will upload the image to the image directory and store a reference to that image. The behavior can then handle size, mime type, etc. Then add a file upload form to the controller and when the data goes to the model to be saved, it will automatically upload the image and put it where it goes.
If you do not want to build your own, here is a very popular behavior that someone has built.
https://github.com/jrbasso/MeioUpload
Or you could try this simple way of doing it (check the readme.md file) :
https://github.com/malikov/cakephp2.0-image-upload

How to load an image with unique names from a private folder?

I am working on an app for iPad where I want to have lets say 100 jpg's in a folder.
They could be named like 01.jpg, 02.jpg etc.
In my app I like to browse those images and when clicking on one of them I need the name of the image to be able to send some data over the network (the data part works fine).
I tried to use UIImagePicker but I found out there are no name connected to the actual image.
Then I made another approach where I have a number of pages where I have buttons and here I load in the images which works fine as long the are a part of the recourse of the project...
But here comes the real problem.
The user of the app should be able to change those images over time without recompiling the app.
So I do look for a way to have a folder where the user can place/replace images with the names 01.jpg etc and the app to use those updated images.
Ideas are very welcome.
Wiljan
I am not sure that I understand what you mean, but You can save images in your application documents folder. You can find more details at:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW6
You can also use NSFileManager to copy files.
what I suggest to do is :
put default images on project resources.
At first start, copy files to documents folder.
always use images from documents folder.