mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-02 22:35:53 +02:00
support GridFS
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
import db from '../../db/mongodb';
|
||||
import * as mongodb from 'mongodb';
|
||||
import monkDb, { nativeDbConn } from '../../db/mongodb';
|
||||
|
||||
const collection = db.get('drive_files');
|
||||
const collection = monkDb.get('drive_files.files');
|
||||
|
||||
(collection as any).createIndex('hash'); // fuck type definition
|
||||
|
||||
export default collection as any; // fuck type definition
|
||||
|
||||
const getGridFSBucket = async (): Promise<mongodb.GridFSBucket> => {
|
||||
const db = await nativeDbConn()
|
||||
const bucket = new mongodb.GridFSBucket(db, {
|
||||
bucketName: 'drive_files'
|
||||
})
|
||||
return bucket
|
||||
}
|
||||
|
||||
export { getGridFSBucket }
|
||||
|
||||
export function validateFileName(name: string): boolean {
|
||||
return (
|
||||
(name.trim().length > 0) &&
|
||||
|
||||
Reference in New Issue
Block a user