@sprucelabs/spruce-image-utils 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
|
+
export default class RemoteImageUploader {
|
|
3
|
+
static upload(options: RemoteImageUploadOptions): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Images.v2022_05_31.UploadResponsePayloadSchema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Images.v2022_05_31.UploadResponsePayloadSchema, false>>>;
|
|
4
|
+
}
|
|
5
|
+
interface RemoteImageUploadOptions {
|
|
6
|
+
client: MercuryClient;
|
|
7
|
+
base64: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { assertOptions } from '@sprucelabs/schema';
|
|
11
|
+
export default class RemoteImageUploader {
|
|
12
|
+
static upload(options) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const { client, base64, name } = assertOptions(options, [
|
|
15
|
+
'client',
|
|
16
|
+
'base64',
|
|
17
|
+
'name',
|
|
18
|
+
]);
|
|
19
|
+
const [image] = yield client.emitAndFlattenResponses('images.upload::v2022_05_31', {
|
|
20
|
+
payload: {
|
|
21
|
+
base64Body: base64,
|
|
22
|
+
name,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return image;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|