73 lines
2.4 KiB
JavaScript
73 lines
2.4 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
require("dotenv/config");
|
|
const upload_1 = require("../upload");
|
|
const log_1 = require("../log");
|
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
const EXPIRATION = 3600; //1 hour
|
|
const log = (0, log_1.createLog)('files');
|
|
async function processUpload(filePath) {
|
|
const config = {
|
|
region: 'us-east-1',
|
|
bucketName: 'your-bucket-name',
|
|
expirationSeconds: EXPIRATION
|
|
};
|
|
log.info(`Started upload: ${filePath}`);
|
|
const result = await (0, upload_1.upload)('test', filePath, config);
|
|
if (result.success) {
|
|
log.info('File ${filePath} uploaded successfully!');
|
|
log.info('Private URL:', result.url);
|
|
}
|
|
else {
|
|
log.error('Upload failed:', result.error);
|
|
}
|
|
}
|
|
async function main() {
|
|
chokidar_1.default.watch('./watch', { ignored: /(^|[/\\])\../ }).on('all', (event, path) => {
|
|
log.info(`File ${path} changed with event type ${event}`);
|
|
});
|
|
}
|
|
main().catch(log.error);
|
|
/*
|
|
const minioResult = await uploadFileToS3('/path/to/your/file.pdf', {
|
|
region: 'us-east-1', // Region can be any string for MinIO
|
|
endpoint: 'https://minio.your-domain.com',
|
|
bucketName: 'your-minio-bucket',
|
|
credentials: {
|
|
accessKeyId: 'your-minio-access-key',
|
|
secretAccessKey: 'your-minio-secret-key'
|
|
},
|
|
forcePathStyle: true, // Important for most S3-compatible services
|
|
expirationSeconds: 3600
|
|
});
|
|
|
|
// Example 3: DigitalOcean Spaces
|
|
const spacesResult = await uploadFileToS3('/path/to/your/file.pdf', {
|
|
region: 'nyc3', // DigitalOcean datacenter region
|
|
endpoint: 'https://nyc3.digitaloceanspaces.com',
|
|
bucketName: 'your-space-name',
|
|
credentials: {
|
|
accessKeyId: 'your-spaces-key',
|
|
secretAccessKey: 'your-spaces-secret'
|
|
},
|
|
forcePathStyle: true,
|
|
expirationSeconds: 7200 // 2 hours
|
|
});
|
|
|
|
// Example 4: Wasabi
|
|
const wasabiResult = await uploadFileToS3('/path/to/your/file.pdf', {
|
|
region: 'us-east-1',
|
|
endpoint: 'https://s3.wasabisys.com',
|
|
bucketName: 'your-wasabi-bucket',
|
|
credentials: {
|
|
accessKeyId: 'your-wasabi-access-key',
|
|
secretAccessKey: 'your-wasabi-secret-key'
|
|
},
|
|
forcePathStyle: true,
|
|
expirationSeconds: 86400 // 24 hours
|
|
});
|
|
*/
|
|
//# sourceMappingURL=index.js.map
|