|
@@ -24,7 +24,12 @@ export const X_GROWI_TRANSFER_KEY_HEADER_NAME = 'x-growi-transfer-key';
|
|
|
export type IDataGROWIInfo = {
|
|
export type IDataGROWIInfo = {
|
|
|
version: string
|
|
version: string
|
|
|
userUpperLimit: number | null // Handle null as Infinity
|
|
userUpperLimit: number | null // Handle null as Infinity
|
|
|
- attachmentInfo: any
|
|
|
|
|
|
|
+ attachmentInfo: {
|
|
|
|
|
+ type: string,
|
|
|
|
|
+ bucket?: string,
|
|
|
|
|
+ customEndpoint?: string, // for S3
|
|
|
|
|
+ uploadNamespace?: string, // for GCS
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface Pusher {
|
|
interface Pusher {
|
|
@@ -49,7 +54,7 @@ interface Pusher {
|
|
|
* @param {string[]} collections Collection name string array
|
|
* @param {string[]} collections Collection name string array
|
|
|
* @param {any} optionsMap Options map
|
|
* @param {any} optionsMap Options map
|
|
|
*/
|
|
*/
|
|
|
- startTransfer(tk: TransferKey, user: any, collections: string[], optionsMap: any): Promise<void>
|
|
|
|
|
|
|
+ startTransfer(tk: TransferKey, user: any, toGROWIInfo: IDataGROWIInfo, collections: string[], optionsMap: any): Promise<void>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface Receiver {
|
|
interface Receiver {
|
|
@@ -213,7 +218,7 @@ export class G2GTransferPusherService implements Pusher {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public async startTransfer(tk: TransferKey, user: any, collections: string[], optionsMap: any): Promise<void> {
|
|
|
|
|
|
|
+ public async startTransfer(tk: TransferKey, user: any, toGROWIInfo: IDataGROWIInfo, collections: string[], optionsMap: any): Promise<void> {
|
|
|
let zipFileStream: ReadStream;
|
|
let zipFileStream: ReadStream;
|
|
|
try {
|
|
try {
|
|
|
const shouldEmit = false;
|
|
const shouldEmit = false;
|
|
@@ -227,6 +232,32 @@ export class G2GTransferPusherService implements Pusher {
|
|
|
throw err;
|
|
throw err;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (toGROWIInfo.attachmentInfo.type === 'none') {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const targetConfigKeys = [
|
|
|
|
|
+ 'app:fileUploadType',
|
|
|
|
|
+ 'app:useOnlyEnvVarForFileUploadType',
|
|
|
|
|
+ 'aws:referenceFileWithRelayMode',
|
|
|
|
|
+ 'aws:lifetimeSecForTemporaryUrl',
|
|
|
|
|
+ 'gcs:apiKeyJsonPath',
|
|
|
|
|
+ 'gcs:bucket',
|
|
|
|
|
+ 'gcs:uploadNamespace',
|
|
|
|
|
+ 'gcs:referenceFileWithRelayMode',
|
|
|
|
|
+ 'gcs:useOnlyEnvVarsForSomeOptions',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ const updateConfigs = Object.fromEntries(targetConfigKeys.map((key) => {
|
|
|
|
|
+ return [key, this.crowi.configManager.getConfig('crowi', key)];
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ await this.crowi.configManager.updateConfigsInTheSameNamespace('crowi', updateConfigs);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ logger.error(err);
|
|
|
|
|
+ throw err;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Send a zip file to other growi via axios
|
|
// Send a zip file to other growi via axios
|
|
|
try {
|
|
try {
|
|
|
// Use FormData to immitate browser's form data object
|
|
// Use FormData to immitate browser's form data object
|