File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (106 lines) | stat: -rw-r--r-- 2,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
Package objects contains functionality for working with Object Storage
object resources. An object is a resource that represents and contains data
- such as documents, images, and so on. You can also store custom metadata
with an object.

Note: When referencing the Object Storage API docs, some of the API actions
are listed under "containers" rather than "objects". This was an intentional
design in Gophercloud to make some object actions feel more natural.

Example to List Objects

	containerName := "my_container"

	listOpts := objects.ListOpts{
		Full: true,
	}

	allPages, err := objects.List(objectStorageClient, containerName, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allObjects, err := objects.ExtractInfo(allPages)
	if err != nil {
		panic(err)
	}

	for _, object := range allObjects {
		fmt.Printf("%+v\n", object)
	}

Example to List Object Names

	containerName := "my_container"

	listOpts := objects.ListOpts{
		Full: false,
	}

	allPages, err := objects.List(objectStorageClient, containerName, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allObjects, err := objects.ExtractNames(allPages)
	if err != nil {
		panic(err)
	}

	for _, object := range allObjects {
		fmt.Printf("%+v\n", object)
	}

Example to Create an Object

	content := "some object content"
	objectName := "my_object"
	containerName := "my_container"

	createOpts := objects.CreateOpts{
		ContentType: "text/plain"
		Content:     strings.NewReader(content),
	}

	object, err := objects.Create(objectStorageClient, containerName, objectName, createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Copy an Object

	objectName := "my_object"
	containerName := "my_container"

	copyOpts := objects.CopyOpts{
		Destination: "/newContainer/newObject",
	}

	object, err := objects.Copy(objectStorageClient, containerName, objectName, copyOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Delete an Object

	objectName := "my_object"
	containerName := "my_container"

	object, err := objects.Delete(objectStorageClient, containerName, objectName).Extract()
	if err != nil {
		panic(err)
	}

Example to Download an Object's Data

	objectName := "my_object"
	containerName := "my_container"

	object := objects.Download(objectStorageClient, containerName, objectName, nil)
	content, err := object.ExtractContent()
	if err != nil {
		panic(err)
	}
*/
package objects