mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-26 18:16:47 -05:00
docs(graph): mention the v1beta1 route for space images
A space image can be assigned with a PATCH of the drive on the v1beta1 route as well, and the size limit applies there the same way. Say so in the README, and cover the refusal of a too large image on that route in the tests. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
67e210a541
commit
dd93fd4d43
2 files changed
+23
-6
No files matched your search
@@ -58,8 +58,9 @@ on the filters supported when querying users.
|
||||
## Space Images
|
||||
|
||||
The image of a space is a file in the space, usually in its `.space` folder. A space manager
|
||||
uploads the file, and then assigns it with `PATCH /graph/v1.0/drives/{drive-id}`, naming the id of
|
||||
the file in the `image` entry of `special`:
|
||||
uploads the file, and then assigns it with `PATCH /graph/v1.0/drives/{drive-id}` (or
|
||||
`PATCH /graph/v1beta1/drives/{drive-id}`, which works the same way), naming the id of the file in
|
||||
the `image` entry of `special`:
|
||||
|
||||
```bash
|
||||
# upload the image into the .space folder of the space; the response header
|
||||
|
||||
@@ -69,8 +69,9 @@ var _ = Describe("setting the image of a space", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
// sends a PATCH of the space with the given file as its special folder
|
||||
patchSpecial := func(folder, fileID string) {
|
||||
// sends a PATCH of the space with the given file as its special folder to
|
||||
// the given handler
|
||||
patchSpecialVia := func(update http.HandlerFunc, path, folder, fileID string) {
|
||||
drive := libregraph.NewDriveUpdate()
|
||||
drive.SetSpecial([]libregraph.DriveItem{{
|
||||
Id: libregraph.PtrString(fileID),
|
||||
@@ -79,11 +80,16 @@ var _ = Describe("setting the image of a space", func() {
|
||||
body, err := json.Marshal(drive)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
r := httptest.NewRequest(http.MethodPatch, "/graph/v1.0/drives/{driveID}/", bytes.NewBuffer(body))
|
||||
r := httptest.NewRequest(http.MethodPatch, path, bytes.NewBuffer(body))
|
||||
rctx := chi.NewRouteContext()
|
||||
rctx.URLParams.Add("driveID", "storageid$spaceid")
|
||||
r = r.WithContext(context.WithValue(ctx, chi.RouteCtxKey, rctx))
|
||||
svc.UpdateDrive(rr, r)
|
||||
update(rr, r)
|
||||
}
|
||||
|
||||
// sends a PATCH of the space with the given file as its special folder
|
||||
patchSpecial := func(folder, fileID string) {
|
||||
patchSpecialVia(svc.UpdateDrive, "/graph/v1.0/drives/{driveID}/", folder, fileID)
|
||||
}
|
||||
|
||||
// the stat of the image file answers with the given size
|
||||
@@ -149,6 +155,16 @@ var _ = Describe("setting the image of a space", func() {
|
||||
expectNothingStored()
|
||||
})
|
||||
|
||||
It("refuses an image above the maximum size on the v1beta1 route too", func() {
|
||||
updateSucceeds()
|
||||
statReturnsSize(1001)
|
||||
|
||||
patchSpecialVia(svc.UpdateDriveV1Beta1, "/graph/v1beta1/drives/{driveID}/", "image", imageID)
|
||||
|
||||
Expect(rr.Code).To(Equal(http.StatusRequestEntityTooLarge))
|
||||
expectNothingStored()
|
||||
})
|
||||
|
||||
It("accepts an image of exactly the maximum size", func() {
|
||||
updateSucceeds()
|
||||
statReturnsSize(1000) // KB is 1000 bytes, KiB would be 1024
|
||||
|
||||
Reference in new issue
Block a user