Skip to content

Commit

Permalink
feat: useSignedUrl returns 501 for getObject and putObject #7 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Aug 30, 2022
1 parent 4357e98 commit c3f4ece
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
21 changes: 19 additions & 2 deletions adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ export default function (root) {
* @param {StorageObject}
* @returns {Promise<Response>}
*/
function putObject({ bucket, object, stream }) {
function putObject({ bucket, object, stream, useSignedUrl }) {
if (useSignedUrl) {
return Promise.resolve(
HyperErr({
status: 501,
msg: "Not Implemented",
}),
);
}
// Create Writer
return Async.of(resolvePath(bucket, object))
.chain(create)
Expand Down Expand Up @@ -150,7 +158,16 @@ export default function (root) {
* @param {StorageInfo}
* @returns {Promise<stream>}
*/
function getObject({ bucket, object }) {
function getObject({ bucket, object, useSignedUrl }) {
if (useSignedUrl) {
return Promise.resolve(
HyperErr({
status: 501,
msg: "Not Implemented",
}),
);
}

return Async.of(resolvePath(bucket, object))
.chain((p) => open(p, { read: true, write: false }))
.bimap(
Expand Down
32 changes: 32 additions & 0 deletions adapter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ Deno.test("fs adapter put object", async () => {
});
});

Deno.test("fs adapter put object - useSignedUrl", async () => {
// setup
const bucket = v4();
const object = v4() + ".txt";
await adapter.makeBucket(bucket);

// test
const result = await adapter.putObject({
bucket,
object,
useSignedUrl: true,
}).catch((err) => err);
assert(!result.ok);
assert(result.status === 501);
});

Deno.test("fs adapter get object", async () => {
const bucket = v4();
const object = v4() + ".txt";
Expand Down Expand Up @@ -193,6 +209,22 @@ Deno.test("fs adapter get object", async () => {
});
});

Deno.test("fs adapter get object - useSignedUrl", async () => {
// setup
const bucket = v4();
const object = v4() + ".txt";
await adapter.makeBucket(bucket);

// test
const result = await adapter.getObject({
bucket,
object,
useSignedUrl: true,
}).catch((err) => err);
assert(!result.ok);
assert(result.status === 501);
});

Deno.test("list files", async () => {
const bucket = v4();
const object = v4() + ".tmp";
Expand Down
4 changes: 2 additions & 2 deletions test/hyper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Harness deps
import { default as appOpine } from "https://x.nest.land/hyper-app-opine@2.0.0/mod.js";
import { default as core } from "https://x.nest.land/hyper@3.0.0/mod.js";
import { default as appOpine } from "https://x.nest.land/hyper-app-opine@2.2.0/mod.js";
import { default as core } from "https://x.nest.land/hyper@3.3.0/mod.js";

import fs from "../mod.js";

Expand Down

0 comments on commit c3f4ece

Please sign in to comment.