func GetObjectWithCondition() { DeleteTestBucketAndObject() defer DeleteTestBucketAndObject() sc := s3lib.NewS3(endpoint, accessKey, secretKey) // Create a bucket err := sc.MakeBucket(bucketName) if err != nil { HandleError(err) } // Put a file f, err := os.Open(localFilePath) defer f.Close() if err != nil { HandleError(err) } err = sc.PutObject(bucketName, objectKey, f) if err != nil { HandleError(err) } date1 := time.Date(2021, time.November, 10, 16, 0, 0, 0, time.Local) data2 := time.Date(2021, time.November, 15, 16, 0, 0, 0, time.Local) params := &s3.GetObjectInput{ Bucket: aws.String(bucketName), Key: aws.String(objectKey), IfModifiedSince: aws.Time(data2), IfUnmodifiedSince: aws.Time(date1), //IfMatch: aws.String("etag"), //IfNoneMatch: aws.String("etag"), } _, err = sc.Client.GetObject(params) if err != nil { HandleError(err) } fmt.Printf("GetObjectWithConditionSample Run Success !\n\n") } |