An open API service indexing awesome lists of open source software.

https://github.com/yjmorales/php_azure_blob_storage

Uploading and rendering images to/from Azure Blob Storage. Symfony application
https://github.com/yjmorales/php_azure_blob_storage

azure blob-storage php symfony

Last synced: 8 months ago
JSON representation

Uploading and rendering images to/from Azure Blob Storage. Symfony application

Awesome Lists containing this project

README

          

## Upload images to Azure Blob Storage using PHP

How to upload images to [Azure Blob Storage](https://learn.microsoft.com/en-us/azure/storage/blobs/) using PHP?
That's the intention of this project: "Upload Images to Azure Blob Storage using PHP" .

The approach to solve the problem is:
1. An endpoint to upload the image.
2. A page to visualize the uploaded image.

This project consists in a small symfony app holding both of them; the endpoint and the visualization page.

### Important Note:

This project assumes you are subscribed to Azure Blob Storage service and:

1. A storage account is created and configured correctly.
2. The authentication/authorization is done by using Azure Active Directory service.
3. The authentication by Key Access must be disabled. It's not a good practice in
terms of security.
4. The following config values are required by this project:
- Storage Account Name
- Client Id
- TenantId
- Client Secret

#### Note: It's out of scope how to set up an Azure Storage Account

### Installation

- git clone git@github.com:yjmorales/php_azure_blob_storage.git
- cd php_azure_blob_storage
- composer install

### Virtual host

In case this example is hosted by apache, the following is a VHost configuration example you can use:


ServerName myazureblobstorage.com
ServerAlias www.myazureblobstorage.com
DirectoryIndex index.php
ServerAdmin email@domain.com
DocumentRoot "/var/www/html/php_azure_blob_storage/public"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /index.php


Note: The above config is just an example.

### Update /etc/hosts file

In case apache is running on the same development station a new entry to the local
host file is needed:

{local_ip} myazureblobstorage.com

Where **local_ip** is the ip of the local server ip

### Implementation - Endpoint

- **Endpoint:** https://myazureblobstorage.com/upload
- **Method:** POST
- Payload:

{
"imageBase64": ""
}

Where `image_base_64_content` should be a valid base64 image content.

- **Response:** The response is a JSON response:

{
'success': true|false,
'errors': [],
'code': int
}

### Implementation - Page to Visualize the uploaded image

myazureblobstorage.com/

### Contact me

Yenier Jimenez


http://yenierjimenez.com


yjmorales86@gmail.com