|
@@ -7,7 +7,7 @@ import (
|
|
"testing"
|
|
"testing"
|
|
)
|
|
)
|
|
|
|
|
|
-// 删除出了 callback 文件之外的所有文件
|
|
|
|
|
|
+// 删除除了 callback 文件之外的所有文件
|
|
func TestDeleteExceptCallback(t *testing.T) {
|
|
func TestDeleteExceptCallback(t *testing.T) {
|
|
// Define OSS configuration
|
|
// Define OSS configuration
|
|
endpoint := "http://pji-bucket1.oss.icvdc.com"
|
|
endpoint := "http://pji-bucket1.oss.icvdc.com"
|
|
@@ -89,3 +89,115 @@ func TestDeleteExceptCallback(t *testing.T) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 删除指定csv文件,为了重新升成 report.pdf
|
|
|
|
+func TestDeleteAllTrajectoryPjiCsv(t *testing.T) {
|
|
|
|
+ // Define OSS configuration
|
|
|
|
+ endpoint := "http://pji-bucket1.oss.icvdc.com"
|
|
|
|
+ accessKeyID := "n8glvFGS25MrLY7j"
|
|
|
|
+ accessKeySecret := "xZ2Fozoarpfw0z28FUhtg8cu0yDc5d"
|
|
|
|
+ bucketName := "pji-bucket1"
|
|
|
|
+
|
|
|
|
+ // Create an OSS client
|
|
|
|
+ client, err := oss.New(endpoint, accessKeyID, accessKeySecret, oss.UseCname(true))
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Failed to create OSS client: %v\n", err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Get the bucket
|
|
|
|
+ bucket, err := client.Bucket(bucketName)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Failed to get bucket: %v\n", err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Define directories to scan
|
|
|
|
+ directories := []string{
|
|
|
|
+ "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse",
|
|
|
|
+ "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse",
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, dir := range directories {
|
|
|
|
+ // List objects in the given prefix
|
|
|
|
+ hasNext := true
|
|
|
|
+ marker := ""
|
|
|
|
+
|
|
|
|
+ for hasNext {
|
|
|
|
+ lsRes, err := bucket.ListObjects(oss.Prefix(dir), oss.Marker(marker))
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Failed to list objects in directory %s: %v\n", dir, err)
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, object := range lsRes.Objects {
|
|
|
|
+ if strings.Contains(object.Key, "trajectory_pji.csv") {
|
|
|
|
+ if err := bucket.DeleteObject(object.Key); err != nil {
|
|
|
|
+ fmt.Printf("Failed to delete %s: %v\n", object.Key, err)
|
|
|
|
+ } else {
|
|
|
|
+ fmt.Printf("Deleted %s\n", object.Key)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hasNext = lsRes.IsTruncated
|
|
|
|
+ marker = lsRes.NextMarker
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 删除
|
|
|
|
+func TestDeletePcd(t *testing.T) {
|
|
|
|
+ // Define OSS configuration
|
|
|
|
+ endpoint := "http://pji-bucket1.oss.icvdc.com"
|
|
|
|
+ accessKeyID := "n8glvFGS25MrLY7j"
|
|
|
|
+ accessKeySecret := "xZ2Fozoarpfw0z28FUhtg8cu0yDc5d"
|
|
|
|
+ bucketName := "pji-bucket1"
|
|
|
|
+
|
|
|
|
+ // Create an OSS client
|
|
|
|
+ client, err := oss.New(endpoint, accessKeyID, accessKeySecret, oss.UseCname(true))
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Failed to create OSS client: %v\n", err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Get the bucket
|
|
|
|
+ bucket, err := client.Bucket(bucketName)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Failed to get bucket: %v\n", err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Define directories to scan
|
|
|
|
+ directories := []string{
|
|
|
|
+ "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse",
|
|
|
|
+ "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse",
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, dir := range directories {
|
|
|
|
+ // List objects in the given prefix
|
|
|
|
+ hasNext := true
|
|
|
|
+ marker := ""
|
|
|
|
+
|
|
|
|
+ for hasNext {
|
|
|
|
+ lsRes, err := bucket.ListObjects(oss.Prefix(dir), oss.Marker(marker))
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Failed to list objects in directory %s: %v\n", dir, err)
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, object := range lsRes.Objects {
|
|
|
|
+ if strings.Contains(object.Key, "pcd_overlook.mp4") {
|
|
|
|
+ if err := bucket.DeleteObject(object.Key); err != nil {
|
|
|
|
+ fmt.Printf("Failed to delete %s: %v\n", object.Key, err)
|
|
|
|
+ } else {
|
|
|
|
+ fmt.Printf("Deleted %s\n", object.Key)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hasNext = lsRes.IsTruncated
|
|
|
|
+ marker = lsRes.NextMarker
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|