Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use minIO in Apache

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to use minIO in Apache. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Docker starts minio to create the data and configuration directory of minio under / home to start the minio service docker run-d-p 9000 minio 9000-- name minio\-- net=host\-e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE"\-e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"\-v / home/minio/data:/data-v / home/minio/config:/root/.minio\ minio/minio server / data

-- net exposes that ip can be accessed externally

Account and password of MINIO_ACCESS_KEY and MINIO_SECRET_KEY for browsers to access the service

-v / home/minio/data:/data is used to mount container data to host-v / home/minio/config:/root/.minio is used to mount container configuration to host

Browsers access minio http://172.18.0.64:9000/

Api uses installation minio to rely on go get-u github.com/minio/minio-go to write test cases package mainimport ("fmt"github.com/minio/minio-go"hydrogen.com/library/utils/log") const (endpoint = "172.18.0.64 AKIAIOSFODNN7EXAMPLE 9000" accessKeyID = "AKIAIOSFODNN7EXAMPLE" secretAccessKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" useSSL = false) func upload ( ) {/ / initialize the minio client object. MinioClient, err: = minio.New (endpoint, accessKeyID, secretAccessKey, useSSL) if err! = nil {log.Fatal (err)} log.Infof ("% s\ n", minioClient) / / minioClient initialized successfully / / created a bucket called mymusic. BucketName: = "hydrogen" location: = "cn-north-1" err = minioClient.MakeBucket (bucketName, location) if err! = nil {/ / check whether the bucket already exists. Exists, err: = minioClient.BucketExists (bucketName) if err = = nil & & exists {log.Infof ("We already own% s\ n", bucketName)} else {log.Fatal (err)}} log.Infof ("Successfully created% s\ n", bucketName) / / upload a zip file. ObjectName: = "iris.txt" filePath: = "E:/iris.txt" contentType: = "text/plain" / / upload a zip file using FPutObject. N, err: = minioClient.FPutObject (bucketName, objectName, filePath, minio.PutObjectOptions {ContentType:contentType}) if err! = nil {log.Fatal (err)} log.Infof ("Successfully uploaded% s of size% d\ n", objectName, n)} func getObject () {/ / initialize the minio client object. MinioClient, err: = minio.New (endpoint, accessKeyID, secretAccessKey, useSSL) if err! = nil {log.Fatal (err)} log.Infof ("% s\ n", minioClient) / / minioClient initialized successfully / / created a bucket called mymusic. BucketName: = "hydrogen" objectName: = "iris.txt" object, err: = minioClient.GetObject (bucketName, objectName, minio.GetObjectOptions {}) if err! = nil {fmt.Println (err) return} log.Infof ("% s\ n", object)} func getFObject () {/ / initializes the minio client object. MinioClient, err: = minio.New (endpoint, accessKeyID, secretAccessKey, useSSL) if err! = nil {log.Fatal (err)} log.Infof ("% s\ n", minioClient) / / minioClient initialized successfully / / created a bucket called mymusic. BucketName: = "hydrogen" objectName: = "iris.txt" filePath: = "E:/test/iris.txt" err = minioClient.FGetObject (bucketName, objectName, filePath Minio.GetObjectOptions {}) if err! = nil {fmt.Println (err) return}} func main () {/ / upload upload () / / download to local getFObject ()} above is how to use minIO in Apache Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report