使用go sdk进行ceph s3 分片上传和分段下载

本文介绍了如何利用Go语言的SDK进行Ceph S3存储的分片上传和分段下载操作,详细阐述了关键步骤和技术要点。
摘要由CSDN通过智能技术生成
package main

import (
	"bufio"
	"bytes"
	"errors"
	"fmt"
	"github.com/astaxie/beego"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/s3"
	"io"
	"os"
)

type CephMgmt struct {
	host        string `ceph host`
	DoName      string `ceph doname`
	bucket_id   string `bucket_id`
	PathStyle   bool   `ceph url style, true means you can use host directly,  false means bucket_id.doname will be used`
	AccessKey   string `aws s3 aceessKey`
	SecretKey   string `aws s3 secretKey`
	block_size int64  `block_size`
}

var Ceph CephMgmt

type MyProvider struct{}

func (m *MyProvider) Retrieve() (credentials.Value, error) {

	return credentials.Value{
		AccessKeyID:     Ceph.AccessKey, //"9YGYCFH1V3QUT4B9KZD1",
		SecretAccessKey: Ceph.SecretKey, //"9hdiwSjCfyrZPKGObH8Kctdur8PiBPJu3B4zGYaZ",
	}, nil
}
func (m *MyProvider) IsExpired() bool { return false }

func (this *CephMgmt) Init() error {
	// "http://s3.devopscloud.com"
	this.host = beego.AppConfig.String("ceph::host")
	if len(this.host) <= 0 {
		return errors.New("ceph conf host is nil")
	}
	this.bucket_id = beego.AppConfig.String("ceph::bucket_id")
	if len(this.bucket_id) <= 0 {
		return errors.New(&
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值