Skip to content

Commit 8374e81

Browse files
author
Jon Scheiding
committed
Support creating new media objects through RCS
Refs MAT-925 flag=none test plan: specs pass Change-Id: I81ed69f55ef471e9a5b8b095b0eacf204115d6e0 Reviewed-on: https://gerrit.instructure.com/c/canvas-rce-api/+/298016 Tested-by: Service Cloud Jenkins <[email protected]> Reviewed-by: Mysti Lilla <[email protected]> QA-Review: Jon Scheiding <[email protected]> Product-Review: Jon Scheiding <[email protected]>
1 parent f3f9e24 commit 8374e81

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/api/mediaObjects.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ function canvasPath(request) {
5858
return canvasPathGET(request);
5959
case "PUT":
6060
return canvasPathPUT(request);
61+
case "POST":
62+
return canvasPathPOST(request);
6163
default:
6264
throw new Error("invalid request");
6365
}
@@ -89,6 +91,10 @@ function canvasPathGET(request) {
8991
return `${baseURI}?per_page=${request.query.per_page}&use_verifiers=0${exclude}${sort}${search}`;
9092
}
9193

94+
function canvasPathPOST() {
95+
return "/api/v1/media_objects";
96+
}
97+
9298
function canvasPathPUT(request) {
9399
const moid = request.params.mediaObjectId;
94100
const user_entered_title = request.query.user_entered_title;
@@ -125,6 +131,7 @@ function transformMediaObject(obj) {
125131
id: obj.media_id,
126132
title: obj.user_entered_title || obj.title,
127133
content_type: obj.media_type,
134+
media_object: obj.media_object,
128135
date: obj.created_at,
129136
published: true, // TODO: is this true?
130137
embedded_iframe_url: obj.embedded_iframe_url

test/service/api/mediaObjects.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ describe("MediaObjects API", () => {
132132
);
133133
});
134134
});
135+
136+
describe("POST", () => {
137+
it("builds the correct path", () => {
138+
const path = canvasPath({ method: "POST" });
139+
assert.strictEqual(path, "/api/v1/media_objects");
140+
});
141+
});
135142
});
136143

137144
describe("canvasResponseHandler()", () => {
@@ -209,7 +216,7 @@ describe("MediaObjects API", () => {
209216
});
210217
});
211218

212-
it("transforms the whole array", () => {
219+
it("transforms the whole files array", () => {
213220
canvasResponseHandler(request, response, canvasResponse);
214221
sinon.assert.calledWithMatch(response.send, val => {
215222
return (

0 commit comments

Comments
 (0)