github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/objectstorage/v1/objects/urls.go (about) 1 package objects 2 3 import ( 4 "net/url" 5 6 "github.com/vnpaycloud-console/gophercloud/v2" 7 v1 "github.com/vnpaycloud-console/gophercloud/v2/openstack/objectstorage/v1" 8 ) 9 10 // tempURL returns an unescaped virtual path to generate the HMAC signature. 11 // Names must not be URL-encoded in this case. 12 // 13 // See: https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#hmac-signature-for-temporary-urls 14 func tempURL(c *gophercloud.ServiceClient, container, object string) string { 15 return c.ServiceURL(container, object) 16 } 17 18 func listURL(c *gophercloud.ServiceClient, container string) (string, error) { 19 if err := v1.CheckContainerName(container); err != nil { 20 return "", err 21 } 22 return c.ServiceURL(url.PathEscape(container)), nil 23 } 24 25 func copyURL(c *gophercloud.ServiceClient, container, object string) (string, error) { 26 if err := v1.CheckContainerName(container); err != nil { 27 return "", err 28 } 29 if err := v1.CheckObjectName(object); err != nil { 30 return "", err 31 } 32 return c.ServiceURL(url.PathEscape(container), url.PathEscape(object)), nil 33 } 34 35 func createURL(c *gophercloud.ServiceClient, container, object string) (string, error) { 36 return copyURL(c, container, object) 37 } 38 39 func getURL(c *gophercloud.ServiceClient, container, object string) (string, error) { 40 return copyURL(c, container, object) 41 } 42 43 func deleteURL(c *gophercloud.ServiceClient, container, object string) (string, error) { 44 return copyURL(c, container, object) 45 } 46 47 func downloadURL(c *gophercloud.ServiceClient, container, object string) (string, error) { 48 return copyURL(c, container, object) 49 } 50 51 func updateURL(c *gophercloud.ServiceClient, container, object string) (string, error) { 52 return copyURL(c, container, object) 53 } 54 55 func bulkDeleteURL(c *gophercloud.ServiceClient) string { 56 return c.Endpoint + "?bulk-delete=true" 57 }