Skip to content

Instantly share code, notes, and snippets.

@joec4i
Created June 11, 2023 12:58
Show Gist options
  • Save joec4i/446e2cc4deb9bc276dc8fdb37559f7a9 to your computer and use it in GitHub Desktop.
Save joec4i/446e2cc4deb9bc276dc8fdb37559f7a9 to your computer and use it in GitHub Desktop.
OpenSwift dir marker tests
package main
import (
"context"
"fmt"
"github.com/ncw/swift/v2"
)
const container = "foo"
func main() {
ctx := context.Background()
con := swift.Connection{
AuthUrl: "http://127.0.0.1:8080/auth/v1.0",
UserName: "test:tester",
ApiKey: "testing",
AuthVersion: 1,
}
err := con.Authenticate(ctx)
if err != nil {
fmt.Printf("Failed to authenticate: %s\n", err)
return
}
err = con.ContainerCreate(ctx, container, nil)
if err != nil {
fmt.Printf("Failed to create container: %s\n", err)
return
}
_, err = con.ObjectPut(ctx, container, "a/b", nil, false, "", "application/directory", nil)
if err != nil {
fmt.Printf("Failed to create directory marker: %s\n", err)
return
}
_, err = con.ObjectPut(ctx, container, "a/b/", nil, false, "", "application/directory", nil)
if err != nil {
fmt.Printf("Failed to create directory marker: %s\n", err)
return
}
_, err = con.ObjectPut(ctx, container, "a/b//", nil, false, "", "application/directory", nil)
if err != nil {
fmt.Printf("Failed to create directory marker: %s\n", err)
return
}
fmt.Println("Directory marker created successfully.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment