mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
use tempdirs
This commit is contained in:
parent
a8d067b195
commit
a7d51cf21b
3 changed files with 22 additions and 13 deletions
|
@ -5,6 +5,8 @@ import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
||||||
import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
|
import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
|
||||||
import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
|
import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
let attachmentBucket;
|
let attachmentBucket;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
attachmentBucket = createBucket('attachments');
|
attachmentBucket = createBucket('attachments');
|
||||||
|
@ -31,6 +33,7 @@ const insertActivity = (fileObj, activityType) =>
|
||||||
Attachments = new FilesCollection({
|
Attachments = new FilesCollection({
|
||||||
debug: false, // Change to `true` for debugging
|
debug: false, // Change to `true` for debugging
|
||||||
collectionName: 'attachments',
|
collectionName: 'attachments',
|
||||||
|
storagePath: os.tmpdir(),
|
||||||
allowClientCode: true,
|
allowClientCode: true,
|
||||||
onAfterUpload: function onAfterUpload(fileRef) {
|
onAfterUpload: function onAfterUpload(fileRef) {
|
||||||
createOnAfterUpload(attachmentBucket).call(this, fileRef);
|
createOnAfterUpload(attachmentBucket).call(this, fileRef);
|
||||||
|
|
|
@ -5,6 +5,8 @@ import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
||||||
import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
|
import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
|
||||||
import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
|
import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
let avatarsBucket;
|
let avatarsBucket;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
avatarsBucket = createBucket('avatars');
|
avatarsBucket = createBucket('avatars');
|
||||||
|
@ -13,6 +15,7 @@ if (Meteor.isServer) {
|
||||||
Avatars = new FilesCollection({
|
Avatars = new FilesCollection({
|
||||||
debug: false, // Change to `true` for debugging
|
debug: false, // Change to `true` for debugging
|
||||||
collectionName: 'avatars',
|
collectionName: 'avatars',
|
||||||
|
storagePath: os.tmpdir(),
|
||||||
allowClientCode: true,
|
allowClientCode: true,
|
||||||
onBeforeUpload(file) {
|
onBeforeUpload(file) {
|
||||||
if (file.size <= 72000 && file.type.startsWith('image/')) {
|
if (file.size <= 72000 && file.type.startsWith('image/')) {
|
||||||
|
|
|
@ -21,9 +21,6 @@ import Swimlanes from '../models/swimlanes';
|
||||||
import Triggers from '../models/triggers';
|
import Triggers from '../models/triggers';
|
||||||
import UnsavedEdits from '../models/unsavedEdits';
|
import UnsavedEdits from '../models/unsavedEdits';
|
||||||
import Users from '../models/users';
|
import Users from '../models/users';
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
// Anytime you change the schema of one of the collection in a non-backward
|
// Anytime you change the schema of one of the collection in a non-backward
|
||||||
// compatible way you have to write a migration in this file using the following
|
// compatible way you have to write a migration in this file using the following
|
||||||
// API:
|
// API:
|
||||||
|
@ -1066,15 +1063,18 @@ Migrations.add('add-hide-logo-by-default', () => {
|
||||||
noValidateMulti,
|
noValidateMulti,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
Migrations.add('migrate-attachments-collectionFS-to-ostrioFilesX', () => {
|
||||||
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
tmdir = os.tmpdir();
|
||||||
|
|
||||||
AttachmentsOld.find().forEach(function(fileObj) {
|
AttachmentsOld.find().forEach(function(fileObj) {
|
||||||
//console.log('File: ', fileObj.userId);
|
//console.log('File: ', fileObj.userId);
|
||||||
|
|
||||||
// This directory must be writable on server, so a test run first
|
// This directory must be writable on server, so a test run first
|
||||||
// We are going to copy the files locally, then move them to S3
|
// We are going to copy the files locally, then move them to mongo bucket
|
||||||
const fileName = `./assets/app/uploads/attachments/${
|
const fileName = path.join(tmpdir, `${fileObj._id}-${fileObj.name()}`);
|
||||||
fileObj._id
|
|
||||||
}-${fileObj.name()}`;
|
|
||||||
const newFileName = fileObj.name();
|
const newFileName = fileObj.name();
|
||||||
|
|
||||||
// This is "example" variable, change it to the userId that you might be using.
|
// This is "example" variable, change it to the userId that you might be using.
|
||||||
|
@ -1132,15 +1132,18 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
||||||
readStream.pipe(writeStream);
|
readStream.pipe(writeStream);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
Migrations.add('migrate-avatars-collectionFS-to-ostrioFilesX', () => {
|
||||||
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
tmdir = os.tmpdir();
|
||||||
|
|
||||||
AvatarsOld.find().forEach(function(fileObj) {
|
AvatarsOld.find().forEach(function(fileObj) {
|
||||||
//console.log('File: ', fileObj.userId);
|
//console.log('File: ', fileObj.userId);
|
||||||
|
|
||||||
// This directory must be writable on server, so a test run first
|
// This directory must be writable on server, so a test run first
|
||||||
// We are going to copy the files locally, then move them to S3
|
// We are going to copy the files locally, then move them to mongo bucket
|
||||||
const fileName = `./assets/app/uploads/avatars/${
|
const fileName = path.join(tmpdir, `${fileObj._id}-${fileObj.name()}`);
|
||||||
fileObj._id
|
|
||||||
}-${fileObj.name()}`;
|
|
||||||
const newFileName = fileObj.name();
|
const newFileName = fileObj.name();
|
||||||
|
|
||||||
// This is "example" variable, change it to the userId that you might be using.
|
// This is "example" variable, change it to the userId that you might be using.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue