Bladeren bron

Modify the function of the position

alzhang 6 jaren geleden
bovenliggende
commit
9472af180e
4 gewijzigde bestanden met toevoegingen van 22 en 20 verwijderingen
  1. 13 0
      sample/append_object.go
  2. 2 2
      sample/config.go
  3. 7 0
      sample/copy_object.go
  4. 0 18
      sample/put_object.go

+ 13 - 0
sample/append_object.go

@@ -146,6 +146,19 @@ func AppendObjectSample() {
 	}
 	fmt.Println("Object ACL:", goar.ACL)
 
+	// Case 6: Set the storage classes.OSS provides three storage classes: Standard, Infrequent Access, and Archive.
+	// Upload a strings, and you can append some strings in the behind of object. but the object is 'Archive' storange class.
+	// An object created with the AppendObject operation is an appendable object. set the object storange-class to 'Archive'.
+	nextPos = 0
+	nextPos, err = bucket.AppendObject(archiveObjectAppendKey, strings.NewReader("昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,"), nextPos, oss.ObjectStorageClass("Archive"))
+	if err != nil {
+		HandleError(err)
+	}
+	nextPos, err = bucket.AppendObject(archiveObjectAppendKey, strings.NewReader("却道海棠依旧。知否?知否?应是绿肥红瘦。"), nextPos)
+	if err != nil {
+		HandleError(err)
+	}
+
 	// Delete the object and bucket
 	err = DeleteTestBucketAndObject(bucketName)
 	if err != nil {

+ 2 - 2
sample/config.go

@@ -21,8 +21,8 @@ var (
 const (
 
 	// The object name in the sample code
-	objectKey       string = "my-object"
-	objectAppendKey string = "my-object-append"
+	objectKey              string = "my-object"
+	archiveObjectAppendKey string = "my-object-append"
 
 	// The local files to run sample code.
 	localFile     string = "src/sample/BingWallpaper-2015-11-07.jpg"

+ 7 - 0
sample/copy_object.go

@@ -104,6 +104,13 @@ func CopyObjectSample() {
 		HandleError(err)
 	}
 
+	// Case 7: Set the storage classes.OSS provides three storage classes: Standard, Infrequent Access, and Archive.
+	// Copy a object in the same bucket, and set object's storage-class to Archive.
+	_, rr := bucket.CopyObject(objectKey, objectKey+"DestArchive", oss.ObjectStorageClass("Archive"))
+	if rr != nil {
+		HandleError(err)
+	}
+
 	// Delete object and bucket
 	err = DeleteTestBucketAndObject(bucketName)
 	if err != nil {

+ 0 - 18
sample/put_object.go

@@ -129,30 +129,12 @@ func PutObjectSample() {
 		HandleError(err)
 	}
 
-	// Copy a object in the same bucket, and set object's storage-class to Archive.
-	_, rr := bucket.CopyObject(objectKey, objectKey+"DestArchive", oss.ObjectStorageClass("Archive"))
-	if rr != nil {
-		HandleError(err)
-	}
-
 	// Upload a local file, and set the object's storage-class to 'Archive'.
 	err = bucket.UploadFile(objectKey, localFile, 100*1024, oss.ObjectStorageClass("Archive"))
 	if err != nil {
 		HandleError(err)
 	}
 
-	// Upload a strings, and you can append some strings in the behind of object. but the object is 'Archive' storange class.
-	// An object created with the AppendObject operation is an appendable object. set the object storange-class to 'Archive'.
-	var nextPos int64
-	nextPos, err = bucket.AppendObject(objectAppendKey, strings.NewReader("昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,"), nextPos, oss.ObjectStorageClass("Archive"))
-	if err != nil {
-		HandleError(err)
-	}
-	nextPos, err = bucket.AppendObject(objectAppendKey, strings.NewReader("却道海棠依旧。知否?知否?应是绿肥红瘦。"), nextPos)
-	if err != nil {
-		HandleError(err)
-	}
-
 	// Delete object and bucket
 	err = DeleteTestBucketAndObject(bucketName)
 	if err != nil {