@sparkstudio/storage-ui 1.0.9 → 1.0.11
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.
- package/dist/index.cjs +39 -7
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +39 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -109,8 +109,23 @@ var Container = class {
|
|
|
109
109
|
if (!response.ok) throw new Error(await response.text());
|
|
110
110
|
return await response.json();
|
|
111
111
|
}
|
|
112
|
-
async
|
|
113
|
-
const url = `${this.baseUrl}/api/Container/
|
|
112
|
+
async DeleteS3(containerDTO) {
|
|
113
|
+
const url = `${this.baseUrl}/api/Container/DeleteS3`;
|
|
114
|
+
const token = localStorage.getItem("auth_token");
|
|
115
|
+
const requestOptions = {
|
|
116
|
+
method: "POST",
|
|
117
|
+
headers: {
|
|
118
|
+
"Content-Type": "application/json",
|
|
119
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
120
|
+
},
|
|
121
|
+
body: JSON.stringify(containerDTO)
|
|
122
|
+
};
|
|
123
|
+
const response = await fetch(url, requestOptions);
|
|
124
|
+
if (!response.ok) throw new Error(await response.text());
|
|
125
|
+
return await response.json();
|
|
126
|
+
}
|
|
127
|
+
async DeleteContainer(id) {
|
|
128
|
+
const url = `${this.baseUrl}/api/Container/DeleteContainer/` + id;
|
|
114
129
|
const token = localStorage.getItem("auth_token");
|
|
115
130
|
const requestOptions = {
|
|
116
131
|
method: "GET",
|
|
@@ -123,8 +138,8 @@ var Container = class {
|
|
|
123
138
|
if (!response.ok) throw new Error(await response.text());
|
|
124
139
|
return await response.json();
|
|
125
140
|
}
|
|
126
|
-
async
|
|
127
|
-
const url = `${this.baseUrl}/api/Container/
|
|
141
|
+
async CreateFileContainer(fileName, size, contentType) {
|
|
142
|
+
const url = `${this.baseUrl}/api/Container/CreateFileContainer/` + fileName + `/` + size + `/` + contentType;
|
|
128
143
|
const token = localStorage.getItem("auth_token");
|
|
129
144
|
const requestOptions = {
|
|
130
145
|
method: "GET",
|
|
@@ -137,6 +152,21 @@ var Container = class {
|
|
|
137
152
|
if (!response.ok) throw new Error(await response.text());
|
|
138
153
|
return await response.json();
|
|
139
154
|
}
|
|
155
|
+
async GetPreSignedUrl(containerDTO) {
|
|
156
|
+
const url = `${this.baseUrl}/api/Container/GetPreSignedUrl`;
|
|
157
|
+
const token = localStorage.getItem("auth_token");
|
|
158
|
+
const requestOptions = {
|
|
159
|
+
method: "POST",
|
|
160
|
+
headers: {
|
|
161
|
+
"Content-Type": "application/json",
|
|
162
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
163
|
+
},
|
|
164
|
+
body: JSON.stringify(containerDTO)
|
|
165
|
+
};
|
|
166
|
+
const response = await fetch(url, requestOptions);
|
|
167
|
+
if (!response.ok) throw new Error(await response.text());
|
|
168
|
+
return await response.json();
|
|
169
|
+
}
|
|
140
170
|
};
|
|
141
171
|
|
|
142
172
|
// src/api/Controllers/Home.ts
|
|
@@ -392,9 +422,11 @@ function HomeView() {
|
|
|
392
422
|
alert(user?.Id);
|
|
393
423
|
}
|
|
394
424
|
const getPresignedUrl = async (file) => {
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
|
|
425
|
+
const sdkDb = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
|
|
426
|
+
const sdkS3 = new SparkStudioStorageSDK("https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod");
|
|
427
|
+
const containerDTO = await sdkDb.container.CreateFileContainer(file.name, file.size, encodeURIComponent(file.type));
|
|
428
|
+
const resultS3 = await sdkS3.container.GetPreSignedUrl(containerDTO);
|
|
429
|
+
return resultS3;
|
|
398
430
|
};
|
|
399
431
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
400
432
|
import_authentication_ui.AuthenticatorProvider,
|
package/dist/index.d.cts
CHANGED
|
@@ -60,8 +60,10 @@ declare class Container {
|
|
|
60
60
|
Read(id: string): Promise<ContainerDTO>;
|
|
61
61
|
Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
|
|
62
62
|
Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
DeleteS3(containerDTO: ContainerDTO): Promise<ContainerDTO>;
|
|
64
|
+
DeleteContainer(id: string): Promise<ContainerDTO>;
|
|
65
|
+
CreateFileContainer(fileName: string, size: number, contentType: string): Promise<ContainerDTO>;
|
|
66
|
+
GetPreSignedUrl(containerDTO: ContainerDTO): Promise<AWSPresignedUrlDTO>;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -60,8 +60,10 @@ declare class Container {
|
|
|
60
60
|
Read(id: string): Promise<ContainerDTO>;
|
|
61
61
|
Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
|
|
62
62
|
Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
DeleteS3(containerDTO: ContainerDTO): Promise<ContainerDTO>;
|
|
64
|
+
DeleteContainer(id: string): Promise<ContainerDTO>;
|
|
65
|
+
CreateFileContainer(fileName: string, size: number, contentType: string): Promise<ContainerDTO>;
|
|
66
|
+
GetPreSignedUrl(containerDTO: ContainerDTO): Promise<AWSPresignedUrlDTO>;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
package/dist/index.js
CHANGED
|
@@ -76,8 +76,23 @@ var Container = class {
|
|
|
76
76
|
if (!response.ok) throw new Error(await response.text());
|
|
77
77
|
return await response.json();
|
|
78
78
|
}
|
|
79
|
-
async
|
|
80
|
-
const url = `${this.baseUrl}/api/Container/
|
|
79
|
+
async DeleteS3(containerDTO) {
|
|
80
|
+
const url = `${this.baseUrl}/api/Container/DeleteS3`;
|
|
81
|
+
const token = localStorage.getItem("auth_token");
|
|
82
|
+
const requestOptions = {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: {
|
|
85
|
+
"Content-Type": "application/json",
|
|
86
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
87
|
+
},
|
|
88
|
+
body: JSON.stringify(containerDTO)
|
|
89
|
+
};
|
|
90
|
+
const response = await fetch(url, requestOptions);
|
|
91
|
+
if (!response.ok) throw new Error(await response.text());
|
|
92
|
+
return await response.json();
|
|
93
|
+
}
|
|
94
|
+
async DeleteContainer(id) {
|
|
95
|
+
const url = `${this.baseUrl}/api/Container/DeleteContainer/` + id;
|
|
81
96
|
const token = localStorage.getItem("auth_token");
|
|
82
97
|
const requestOptions = {
|
|
83
98
|
method: "GET",
|
|
@@ -90,8 +105,8 @@ var Container = class {
|
|
|
90
105
|
if (!response.ok) throw new Error(await response.text());
|
|
91
106
|
return await response.json();
|
|
92
107
|
}
|
|
93
|
-
async
|
|
94
|
-
const url = `${this.baseUrl}/api/Container/
|
|
108
|
+
async CreateFileContainer(fileName, size, contentType) {
|
|
109
|
+
const url = `${this.baseUrl}/api/Container/CreateFileContainer/` + fileName + `/` + size + `/` + contentType;
|
|
95
110
|
const token = localStorage.getItem("auth_token");
|
|
96
111
|
const requestOptions = {
|
|
97
112
|
method: "GET",
|
|
@@ -104,6 +119,21 @@ var Container = class {
|
|
|
104
119
|
if (!response.ok) throw new Error(await response.text());
|
|
105
120
|
return await response.json();
|
|
106
121
|
}
|
|
122
|
+
async GetPreSignedUrl(containerDTO) {
|
|
123
|
+
const url = `${this.baseUrl}/api/Container/GetPreSignedUrl`;
|
|
124
|
+
const token = localStorage.getItem("auth_token");
|
|
125
|
+
const requestOptions = {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: {
|
|
128
|
+
"Content-Type": "application/json",
|
|
129
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
130
|
+
},
|
|
131
|
+
body: JSON.stringify(containerDTO)
|
|
132
|
+
};
|
|
133
|
+
const response = await fetch(url, requestOptions);
|
|
134
|
+
if (!response.ok) throw new Error(await response.text());
|
|
135
|
+
return await response.json();
|
|
136
|
+
}
|
|
107
137
|
};
|
|
108
138
|
|
|
109
139
|
// src/api/Controllers/Home.ts
|
|
@@ -359,9 +389,11 @@ function HomeView() {
|
|
|
359
389
|
alert(user?.Id);
|
|
360
390
|
}
|
|
361
391
|
const getPresignedUrl = async (file) => {
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
|
|
392
|
+
const sdkDb = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
|
|
393
|
+
const sdkS3 = new SparkStudioStorageSDK("https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod");
|
|
394
|
+
const containerDTO = await sdkDb.container.CreateFileContainer(file.name, file.size, encodeURIComponent(file.type));
|
|
395
|
+
const resultS3 = await sdkS3.container.GetPreSignedUrl(containerDTO);
|
|
396
|
+
return resultS3;
|
|
365
397
|
};
|
|
366
398
|
return /* @__PURE__ */ jsxs2(
|
|
367
399
|
AuthenticatorProvider,
|