-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploader.py
37 lines (31 loc) · 908 Bytes
/
uploader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
###
# File: uploader.py
# Project: text-uploader
# File Created: Wednesday, 11th December 2019 10:02:48 pm
# Author: Jaseem Jas ([email protected])
# -----
# Last Modified: Wednesday, 11th December 2019 10:11:55 pm
# Modified By: Jaseem Jas ([email protected])
# -----
# Copyright 2016 - 2019 Socialanimal.com
###
from minio import Minio
from minio.error import ResponseError
from io import BytesIO
host = "localhost:9000"
access_key = "jaseem"
secret_key = "iamminio"
minioClient = Minio(host, access_key=access_key,
secret_key=secret_key, secure=False)
text = "My minio content"
bucket = "text"
content = BytesIO(bytes(text, 'utf-8'))
key = 'sample.text'
size = content.getbuffer().nbytes
try:
minioClient.put_object(bucket, key, content, size)
print("Done!")
except ResponseError as err:
print("error:", err)