mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(storage): add test button when creating channel (not only for existing one) and add region parameter for S3.
This commit is contained in:
@@ -94,7 +94,7 @@ export const AgentForm = (props: agentFormProps) => {
|
||||
<FormItem>
|
||||
<FormLabel>Description</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="This agent is for the client exemple.com" {...field}
|
||||
<Input placeholder="This agent is for the client example.com" {...field}
|
||||
value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormDescription>Enter your project agent description</FormDescription>
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import {eq} from 'drizzle-orm';
|
||||
import {Json} from "drizzle-zod";
|
||||
|
||||
import * as drizzleDb from '@/db';
|
||||
import {db} from '@/db';
|
||||
import type {StorageInput, StorageProviderKind, StorageResult,} from './types';
|
||||
import {dispatchViaProvider} from "@/features/storages/providers";
|
||||
import {StorageChannel} from "@/db/schema/12_storage-channel";
|
||||
import {Json} from "drizzle-zod";
|
||||
import {
|
||||
StorageChannelFormType
|
||||
} from "@/components/wrappers/dashboard/admin/channels/channel/channel-form/channel-form.schema";
|
||||
|
||||
|
||||
export async function dispatchStorage(
|
||||
input: StorageInput,
|
||||
policyId?: string,
|
||||
channelId?: string,
|
||||
channelData?: StorageChannelFormType,
|
||||
organizationId?: string
|
||||
): Promise<StorageResult> {
|
||||
try {
|
||||
@@ -68,6 +74,8 @@ export async function dispatchStorage(
|
||||
};
|
||||
}
|
||||
|
||||
if (channelData) channel = {...channelData, config: channelData.config as Json};
|
||||
|
||||
if (!channel) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -90,7 +98,6 @@ export async function dispatchStorage(
|
||||
channel.provider as StorageProviderKind,
|
||||
channel.config,
|
||||
input,
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {generateFileUrl} from "@/features/storages/helpers";
|
||||
|
||||
type S3Config = {
|
||||
endPointUrl: string;
|
||||
region?: string;
|
||||
accessKey: string;
|
||||
secretKey: string;
|
||||
bucketName: string;
|
||||
@@ -14,6 +15,7 @@ type S3Config = {
|
||||
async function getS3Client(config: S3Config) {
|
||||
return new Minio.Client({
|
||||
endPoint: config.endPointUrl,
|
||||
region: config.region ?? "us-east-1",
|
||||
accessKey: config.accessKey,
|
||||
secretKey: config.secretKey,
|
||||
port: config.port ?? 443,
|
||||
@@ -32,7 +34,7 @@ async function ensureBucket(config: S3Config) {
|
||||
|
||||
export async function uploadS3(
|
||||
config: S3Config,
|
||||
input: { data: StorageUploadInput, metadata?: StorageMetaData }
|
||||
input: { data: StorageUploadInput, metadata?: StorageMetaData }
|
||||
): Promise<StorageResult> {
|
||||
const client = await getS3Client(config);
|
||||
await ensureBucket(config);
|
||||
@@ -72,7 +74,10 @@ export async function uploadS3(
|
||||
|
||||
}
|
||||
|
||||
export async function getS3(config: S3Config, input: { data: StorageGetInput, metadata: StorageMetaData }): Promise<StorageResult> {
|
||||
export async function getS3(config: S3Config, input: {
|
||||
data: StorageGetInput,
|
||||
metadata: StorageMetaData
|
||||
}): Promise<StorageResult> {
|
||||
const client = await getS3Client(config);
|
||||
|
||||
const key = `${BASE_DIR}${input.data.path}`;
|
||||
@@ -97,7 +102,10 @@ export async function getS3(config: S3Config, input: { data: StorageGetInput, me
|
||||
};
|
||||
}
|
||||
|
||||
export async function deleteS3(config: S3Config, input: { data: StorageDeleteInput, metadata?: StorageMetaData }): Promise<StorageResult> {
|
||||
export async function deleteS3(config: S3Config, input: {
|
||||
data: StorageDeleteInput,
|
||||
metadata?: StorageMetaData
|
||||
}): Promise<StorageResult> {
|
||||
const client = await getS3Client(config);
|
||||
const key = `${BASE_DIR}${input.data.path}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user