{"id":427485,"date":"2024-07-26T15:00:06","date_gmt":"2024-07-26T15:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=427485"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=427485","title":{"rendered":"<span>\u0417\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c MinIO \u0438 Postgresql \u0432\u043c\u0435\u0441\u0442\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/min.io\/\" rel=\"noopener noreferrer nofollow\">MinIO<\/a> \u0438 <a href=\"https:\/\/www.postgresql.org\/\" rel=\"noopener noreferrer nofollow\">Postgres<\/a>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414.<br \/>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 MinIO, \u043f\u0440\u043e \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 &#171;<a href=\"https:\/\/habr.com\/ru\/companies\/ozontech\/articles\/586024\/\" rel=\"noopener noreferrer nofollow\"><u>\u0417\u0430\u0447\u0435\u043c \u0438 \u043a\u0430\u043a \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 MinIO<\/u><\/a>&#187; <\/p>\n<h2>\u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u044c\u0448\u0435<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439. <br \/>\u041d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432\/\u0431\u043b\u044e\u0434\/\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u0431\u043b\u044e\u0434 \u0447\u0435\u0440\u0435\u0437 REST API. \u041c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441\u0430\u043c\u0438\u043c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<pre><code class=\"go\">func createRestaurant(ctx *gin.Context) {     \/\/ \u0447\u0442\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438      \/\/ ...        \/\/ \u0417\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430     form, err := ctx.MultipartForm() files := form.File[\"image\"] if len(files) == 0 { ctx.JSON(http.StatusBadRequest, gin.H{ \"error\": \"no photos\", }) return }      \/\/ .... }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u044b \u0448\u043b\u0438 \u0432 \u0411\u0414 \u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0441\u043e\u0445\u0440\u044f\u043d\u044f\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u0434\u0435\u043b\u0430\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438\u044c \u043e\u0431 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u043c. \u0421\u0432\u044f\u0437\u044c \u0443 \u043d\u0430\u0441 <strong>\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c, <\/strong>\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u0435. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ac0\/a8a\/994\/ac0a8a994448a7b640b9d557d35274ba.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445\" title=\"\u0421\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445\" width=\"987\" height=\"302\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ac0\/a8a\/994\/ac0a8a994448a7b640b9d557d35274ba.png\"\/><\/p>\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u043a\u0430\u043a \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u0438\u0435 \u0447\u0430\u0441\u044b, \u043d\u043e \u043c\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0448\u0435\u043b \u043f\u0440\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b MinIO \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f, \u043f\u043e\u0448\u0435\u043b \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<h2>\u041a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c<\/h2>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 S3 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0411\u0414 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e, \u0437\u0430 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u044e\u0442<br \/>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c<strong> <\/strong>\u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 MinIO, \u0433\u0430\u0439\u0434 \u043f\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044e \u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 MinIO \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u0435, \u0447\u0442\u043e \u044f \u0443\u043a\u0430\u0437\u0430\u043b \u0432\u044b\u0448\u0435. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0443 docker-compose.yaml, \u0433\u0434\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c Postgresql \u0438 MinIO<\/p>\n<pre><code>version: '3.8' services:   minio:     container_name: minio     image: minio\/minio     environment:       MINIO_ACCESS_KEY: minio       MINIO_SECRET_KEY: minio123     command: server \/data --console-address \":9001\"     ports:       - \"9000:9000\"       - \"9001:9001\"     volumes:       - minio_data:\/data    postgres:     container_name: postgres     image: postgres:alpine     environment:       POSTGRES_DB: postgres       POSTGRES_USER: postgres       POSTGRES_PASSWORD: 5432     ports:       - \"5432:5432\"     volumes:       - postgres_data:\/var\/lib\/postgresql\/data  volumes:   minio_data:   postgres_data<\/code><\/pre>\n<h4>Postgesql <\/h4>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u0411\u0414 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 <\/p>\n<pre><code>CREATE TABLE IF NOT EXISTS images (     key TEXT,     value JSONB );<\/code><\/pre>\n<h4>Minio<\/h4>\n<p>\u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0431\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0434\u043e \u043d\u0443\u0436\u0435\u043d \u0431\u0430\u043a\u0435\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<pre><code># \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043b\u0438\u0430\u0441\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c mc alias set myminio http:\/\/minio:9000 minio minio123 mc mb myminio\/menus # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u043a\u0435\u0442\u0430 menus <\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code>mc admin config set myminio notify_postgres:minio-postgres connection_string=\"user=postgres password=5432 host=postgres dbname=postgres port=5432 sslmode=disable\" table=\"images\" format=\"namespace\"<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0441 \u043f\u043e\u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 <\/p>\n<pre><code>mc admin service restart myminio<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0437\u0430\u0434\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b MinIO \u0434\u0435\u043b\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u043a\u0435\u0442 menus<\/p>\n<pre><code>mc event add myminio\/menus arn:minio:sqs::minio-postgres:postgresql --event put<\/code><\/pre>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2de\/c91\/db2\/2dec91db229344547f3b946d31ca61a8.png\" alt=\"\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\" title=\"\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\" width=\"594\" height=\"268\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2de\/c91\/db2\/2dec91db229344547f3b946d31ca61a8.png\"\/><\/p>\n<div><figcaption>\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 json \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e \u043e\u0431\u044a\u0435\u043a\u0442<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/74e\/71d\/d12\/74e71dd12d7f4a29efdec41494d9d5d2.png\" alt=\"\u0414\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\" title=\"\u0414\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\" width=\"1824\" height=\"174\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/74e\/71d\/d12\/74e71dd12d7f4a29efdec41494d9d5d2.png\"\/><\/p>\n<div><figcaption>\u0414\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u043b\u0435\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0438\u043b\u0438 \u0431\u043b\u044e\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u0442\u0443 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"go\">func makeMetadata(opts *SaveObjectOptions) map[string]string { return map[string]string{ \"restaurant_id\": opts.RestaurantID, \"category_id\":   opts.CategoryID, \"dish_id\":       opts.DishID, } }  func (c *Client) SaveImage(ctx context.Context, opts *SaveObjectOptions) error { info, err := c.minioClient.FPutObject(ctx, menusBucket, opts.FileName, opts.FilePath, minio.PutObjectOptions{ ContentType:  \"image\/png\", UserMetadata: makeMetadata(opts), }) if err != nil { c.log.Error(\"failed to upload image\", zap.Error(err)) return err }  c.log.Info(\"successfully uploaded of size\", zap.String(\"filename\", opts.FileName), zap.Int64(\"size\", info.Size))  return nil }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043a\u043e\u043c\u0443 \u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0434\u0430\u0447<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/831668\/\"> https:\/\/habr.com\/ru\/articles\/831668\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/min.io\/\" rel=\"noopener noreferrer nofollow\">MinIO<\/a> \u0438 <a href=\"https:\/\/www.postgresql.org\/\" rel=\"noopener noreferrer nofollow\">Postgres<\/a>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414.<br \/>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 MinIO, \u043f\u0440\u043e \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 &#171;<a href=\"https:\/\/habr.com\/ru\/companies\/ozontech\/articles\/586024\/\" rel=\"noopener noreferrer nofollow\"><u>\u0417\u0430\u0447\u0435\u043c \u0438 \u043a\u0430\u043a \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 MinIO<\/u><\/a>&#187; <\/p>\n<h2>\u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u044c\u0448\u0435<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439. <br \/>\u041d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432\/\u0431\u043b\u044e\u0434\/\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u0431\u043b\u044e\u0434 \u0447\u0435\u0440\u0435\u0437 REST API. \u041c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441\u0430\u043c\u0438\u043c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<pre><code class=\"go\">func createRestaurant(ctx *gin.Context) {     \/\/ \u0447\u0442\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438      \/\/ ...        \/\/ \u0417\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430     form, err := ctx.MultipartForm() files := form.File[\"image\"] if len(files) == 0 { ctx.JSON(http.StatusBadRequest, gin.H{ \"error\": \"no photos\", }) return }      \/\/ .... }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u044b \u0448\u043b\u0438 \u0432 \u0411\u0414 \u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0441\u043e\u0445\u0440\u044f\u043d\u044f\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u0434\u0435\u043b\u0430\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438\u044c \u043e\u0431 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u043c. \u0421\u0432\u044f\u0437\u044c \u0443 \u043d\u0430\u0441 <strong>\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c, <\/strong>\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u0435. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u043a\u0430\u043a \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u0438\u0435 \u0447\u0430\u0441\u044b, \u043d\u043e \u043c\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0448\u0435\u043b \u043f\u0440\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b MinIO \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f, \u043f\u043e\u0448\u0435\u043b \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<h2>\u041a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c<\/h2>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 S3 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0411\u0414 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e, \u0437\u0430 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u044e\u0442<br \/>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c<strong> <\/strong>\u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 MinIO, \u0433\u0430\u0439\u0434 \u043f\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044e \u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 MinIO \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u0435, \u0447\u0442\u043e \u044f \u0443\u043a\u0430\u0437\u0430\u043b \u0432\u044b\u0448\u0435. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0443 docker-compose.yaml, \u0433\u0434\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c Postgresql \u0438 MinIO<\/p>\n<pre><code>version: '3.8' services:   minio:     container_name: minio     image: minio\/minio     environment:       MINIO_ACCESS_KEY: minio       MINIO_SECRET_KEY: minio123     command: server \/data --console-address \":9001\"     ports:       - \"9000:9000\"       - \"9001:9001\"     volumes:       - minio_data:\/data    postgres:     container_name: postgres     image: postgres:alpine     environment:       POSTGRES_DB: postgres       POSTGRES_USER: postgres       POSTGRES_PASSWORD: 5432     ports:       - \"5432:5432\"     volumes:       - postgres_data:\/var\/lib\/postgresql\/data  volumes:   minio_data:   postgres_data<\/code><\/pre>\n<h4>Postgesql <\/h4>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u0411\u0414 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 <\/p>\n<pre><code>CREATE TABLE IF NOT EXISTS images (     key TEXT,     value JSONB );<\/code><\/pre>\n<h4>Minio<\/h4>\n<p>\u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0431\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0434\u043e \u043d\u0443\u0436\u0435\u043d \u0431\u0430\u043a\u0435\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<pre><code># \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043b\u0438\u0430\u0441\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c mc alias set myminio http:\/\/minio:9000 minio minio123 mc mb myminio\/menus # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u043a\u0435\u0442\u0430 menus <\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code>mc admin config set myminio notify_postgres:minio-postgres connection_string=\"user=postgres password=5432 host=postgres dbname=postgres port=5432 sslmode=disable\" table=\"images\" format=\"namespace\"<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0441 \u043f\u043e\u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 <\/p>\n<pre><code>mc admin service restart myminio<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0437\u0430\u0434\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b MinIO \u0434\u0435\u043b\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u043a\u0435\u0442 menus<\/p>\n<pre><code>mc event add myminio\/menus arn:minio:sqs::minio-postgres:postgresql --event put<\/code><\/pre>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 json \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e \u043e\u0431\u044a\u0435\u043a\u0442<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0414\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u043b\u0435\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430 \u0438\u043b\u0438 \u0431\u043b\u044e\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u0442\u0443 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"go\">func makeMetadata(opts *SaveObjectOptions) map[string]string { return map[string]string{ \"restaurant_id\": opts.RestaurantID, \"category_id\":   opts.CategoryID, \"dish_id\":       opts.DishID, } }  func (c *Client) SaveImage(ctx context.Context, opts *SaveObjectOptions) error { info, err := c.minioClient.FPutObject(ctx, menusBucket, opts.FileName, opts.FilePath, minio.PutObjectOptions{ ContentType:  \"image\/png\", UserMetadata: makeMetadata(opts), }) if err != nil { c.log.Error(\"failed to upload image\", zap.Error(err)) return err }  c.log.Info(\"successfully uploaded of size\", zap.String(\"filename\", opts.FileName), zap.Int64(\"size\", info.Size))  return nil }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043a\u043e\u043c\u0443 \u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0434\u0430\u0447<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/831668\/\"> https:\/\/habr.com\/ru\/articles\/831668\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-427485","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427485"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427485\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}