pg-mvc-service 2.0.35 → 2.0.37
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.
|
@@ -127,7 +127,10 @@ class AwsS3Client {
|
|
|
127
127
|
ContentType: type
|
|
128
128
|
});
|
|
129
129
|
yield this.client.send(command);
|
|
130
|
-
return
|
|
130
|
+
return {
|
|
131
|
+
url: `${this.UrlPrefix}/${key}`,
|
|
132
|
+
fileName: fileName
|
|
133
|
+
};
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
uploadFromUrl(path, fileName, url) {
|
|
@@ -150,7 +153,10 @@ class AwsS3Client {
|
|
|
150
153
|
});
|
|
151
154
|
yield this.client.send(command);
|
|
152
155
|
// アップロードされたファイルのURLを返す
|
|
153
|
-
return
|
|
156
|
+
return {
|
|
157
|
+
url: this.url(path, fileName),
|
|
158
|
+
fileName: fileName
|
|
159
|
+
};
|
|
154
160
|
}
|
|
155
161
|
catch (error) {
|
|
156
162
|
if (axios_1.default.isAxiosError(error)) {
|
package/package.json
CHANGED
|
@@ -3,6 +3,11 @@ import { Base64Client } from './Base64Client';
|
|
|
3
3
|
import { UnprocessableException } from '../exceptions/Exception';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
|
|
6
|
+
type IUploadResponse = {
|
|
7
|
+
url: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
export class AwsS3Client {
|
|
7
12
|
private client: S3Client;
|
|
8
13
|
|
|
@@ -96,7 +101,7 @@ export class AwsS3Client {
|
|
|
96
101
|
await this.client.send(command);
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
public async uploadBase64Data(path: string, fileName: string, base64Data: string) : Promise<
|
|
104
|
+
public async uploadBase64Data(path: string, fileName: string, base64Data: string) : Promise<IUploadResponse> {
|
|
100
105
|
const base64Client = new Base64Client();
|
|
101
106
|
|
|
102
107
|
const type = base64Client.getMimeType(base64Data);
|
|
@@ -120,10 +125,13 @@ export class AwsS3Client {
|
|
|
120
125
|
});
|
|
121
126
|
await this.client.send(command);
|
|
122
127
|
|
|
123
|
-
return
|
|
128
|
+
return {
|
|
129
|
+
url: `${this.UrlPrefix}/${key}`,
|
|
130
|
+
fileName: fileName
|
|
131
|
+
}
|
|
124
132
|
}
|
|
125
133
|
|
|
126
|
-
public async uploadFromUrl(path: string, fileName: string, url: string): Promise<
|
|
134
|
+
public async uploadFromUrl(path: string, fileName: string, url: string): Promise<IUploadResponse> {
|
|
127
135
|
try {
|
|
128
136
|
// URLからデータを取得
|
|
129
137
|
const response = await axios.get(url, {
|
|
@@ -146,8 +154,10 @@ export class AwsS3Client {
|
|
|
146
154
|
await this.client.send(command);
|
|
147
155
|
|
|
148
156
|
// アップロードされたファイルのURLを返す
|
|
149
|
-
return
|
|
150
|
-
|
|
157
|
+
return {
|
|
158
|
+
url: this.url(path, fileName),
|
|
159
|
+
fileName: fileName
|
|
160
|
+
}
|
|
151
161
|
} catch (error) {
|
|
152
162
|
if (axios.isAxiosError(error)) {
|
|
153
163
|
if (error.response) {
|