<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ### 連接 ~~~ package ceph import ( "gopkg.in/amz.v1/aws" "gopkg.in/amz.v1/s3" ) var ( CephConn *s3.S3 ) func init() { // 初始化ceph信息 auth := aws.Auth{ AccessKey: "", SecretKey: "", } region := aws.Region{ Name:"default", EC2Endpoint:"http://127.0.0.1:9080", S3Endpoint:"http://127.0.0.1:9080", S3BucketEndpoint:"", S3LocationConstraint:false, // 沒有區域限制 S3LowercaseBucket:false, // bucket沒有大小寫限制 Sign:aws.SignV2, } // 創建??s3類型連接 CephConn = s3.New(auth, region) } // 獲取指定Bucker func GetCephBucker(bucket string)*s3.Bucket { return CephConn.Bucket(bucket) } ~~~ ### 簡單操作 ~~~ func TestCeph(t *testing.T) { bucker := ceph.GetCephBucker("testbucket1") // 創建一個新的bucket err := bucker.PutBucket(s3.PublicRead) // 參數權限 if err != nil { t.Log(err.Error()) } // 查詢bucket下面制定條件的object keys result, err := bucker.List("", "", "", 100)// 最多返回100條數據 if err != nil { t.Log(err.Error()) } fmt.Printf("object keys%v \n",result) // 上傳新對象 err = bucker.Put("/a.txt",[]byte("just for test"),"octet-steam",s3.PublicRead) /** bucker.Put("/a.txt",[]byte("just for test"),"octet-steam",s3.PublicRead) put參數 1.在文件系統的絕對路徑 2.內容 3.context-type 4.權限 */ if err != nil { t.Log(err.Error()) } // 查詢下名制定條件的object keys result, err = bucker.List("", "", "", 100)// 最多返回100條數據 if err != nil { t.Log(err.Error()) } fmt.Printf("object keys%v \n",result) } ~~~ ### ceph小結 - 創建bucket ``` bucker := ceph.GetCephBucker("testbucket1") // 創建一個新的bucket err := bucker.PutBucket(s3.PublicRead) // 參數權限 ``` - 上傳文件 ``` filename := "test.txt" bucker := ceph.GetCephBucker("userfile") cephPath := "/ceph/" + filename bytes, _ := ioutil.ReadFile(filename) bucker.Put(cephPath,bytes,"octet-stream",s3.PublicRead) ``` - 下載文件 ``` bucker := ceph.GetCephBucker("userfile") cephPath := "/ceph/test.txt" data, _ := bucker.Get(cephPath) ioutil.WriteFile("hello.text",data,00666) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看