In recent years, file upload has become a common requirement, and in order to avoid the limitation of server storage capacity and facilitate management, we usually choose to use Object Storage Service (OSS) to store files. Alibaba Cloud's OSS service is a good choice because it supports distributed expansion and solves the problem of storage capacity.
However, in some business scenarios, data confidentiality requirements are high, and private deployment is required, that is, an OSS service is built in your own data center. In this case, we can use minio to meet the requirements, which can achieve similar functions as Alibaba Cloud OSS.
First, let's try Alibaba Cloud OSS. In OSS, files are stored in buckets. Let's first create a bucket, and then go to the file list to upload the file. Since the created bucket is set to public read, we can directly access the uploaded files.
In addition, Alibaba Cloud OSS also provides SDKs to implement file upload. Let's create a project and install the ali-oss dependency package. With the SDK, we can specify parameters such as region, bucket, accesskeyid, and accesskeysecret to upload files.
After the file is successfully uploaded, we can access it through the OSS service or through the SDK.
This is how to use Alibaba Cloud OSS. So, let's try to use minio to build our own OSS service.
First of all, we need to install docker desktop and build minio containers through docker. Search for and select the minio image in Docker Desktop, and fill in the corresponding information, such as the container name, port mapping, data directory mounting, and login credentials. After running, we can see that the data directory has been mounted successfully, and the port has also been mapped successfully.
Visit http: localhost:9001 and enter the username and password you just set to enter the management page. Similar to the usage of Alibaba Cloud OSS, in Minio, we can also create buckets and upload files. By clicking"share", we can get the URL of the file and then we can access it through the browser.
Same as Alibaba Cloud OSS, we can also upload files through the minio SDK. After installing the minio dependency package, upload files by specifying parameters such as endpoint, port, accesskey, and secretkey. Similarly, we can also use the SDK to ** files.
Through the above practices, we can find that the use of MINIO is almost the same as that of Alibaba Cloud OSS, and they all follow the Amazon S3 specification. Since the S3 specification has become the industry standard, the usage methods and interfaces of OSS services are very similar.
By using docker to build a minio container, we deployed an OSS service by ourselves. In the management interface and file upload through SDK, we feel that the user experience is almost the same as that of Alibaba Cloud OSS.
Back to your company, do you also need to build your own minio service as OSS storage? By building your own OSS service, your company can better protect sensitive data while also having the flexibility to scale and manage. Whether you choose Alibaba Cloud OSS or build your own minio service, it is very smooth to use, making your file upload and ** more convenient and efficient.
Overall, through the introduction and practice of this article, we have learned how to use Alibaba Cloud OSS and Minio to achieve file upload and **. Whether you choose a paid cloud storage service or build an OSS service yourself, we can choose according to your actual needs. Using OSS provides better scalability and security for our file management. We hope that this article will help you understand and use OSS services.