mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 15:50:32 +00:00
Merge pull request #408 from bigcapitalhq/fix-import-store-absolute-path
fix: absolute storage imports path.
This commit is contained in:
@@ -96,7 +96,6 @@ PLAID_LINK_WEBHOOK=
|
|||||||
PLAID_SANDBOX_REDIRECT_URI=
|
PLAID_SANDBOX_REDIRECT_URI=
|
||||||
PLAID_DEVELOPMENT_REDIRECT_URI=
|
PLAID_DEVELOPMENT_REDIRECT_URI=
|
||||||
|
|
||||||
|
|
||||||
# https://docs.lemonsqueezy.com/guides/developer-guide/getting-started#create-an-api-key
|
# https://docs.lemonsqueezy.com/guides/developer-guide/getting-started#create-an-api-key
|
||||||
LEMONSQUEEZY_API_KEY=
|
LEMONSQUEEZY_API_KEY=
|
||||||
LEMONSQUEEZY_STORE_ID=
|
LEMONSQUEEZY_STORE_ID=
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Multer from 'multer';
|
import Multer from 'multer';
|
||||||
import { ServiceError } from '@/exceptions';
|
import { ServiceError } from '@/exceptions';
|
||||||
|
import { getImportsStoragePath } from '@/services/Import/_utils';
|
||||||
|
|
||||||
export function allowSheetExtensions(req, file, cb) {
|
export function allowSheetExtensions(req, file, cb) {
|
||||||
if (
|
if (
|
||||||
@@ -16,7 +17,8 @@ export function allowSheetExtensions(req, file, cb) {
|
|||||||
|
|
||||||
const storage = Multer.diskStorage({
|
const storage = Multer.diskStorage({
|
||||||
destination: function (req, file, cb) {
|
destination: function (req, file, cb) {
|
||||||
cb(null, './public/imports');
|
const path = getImportsStoragePath();
|
||||||
|
cb(null, path);
|
||||||
},
|
},
|
||||||
filename: function (req, file, cb) {
|
filename: function (req, file, cb) {
|
||||||
// Add the creation timestamp to clean up temp files later.
|
// Add the creation timestamp to clean up temp files later.
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ export class ImportFileUploadService {
|
|||||||
filename: string,
|
filename: string,
|
||||||
params: Record<string, number | string>
|
params: Record<string, number | string>
|
||||||
): Promise<ImportFileUploadPOJO> {
|
): Promise<ImportFileUploadPOJO> {
|
||||||
console.log(filename, 'filename');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.importUnhandled(
|
return await this.importUnhandled(
|
||||||
tenantId,
|
tenantId,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import moment from 'moment';
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
|
import path from 'path';
|
||||||
import {
|
import {
|
||||||
defaultTo,
|
defaultTo,
|
||||||
upperFirst,
|
upperFirst,
|
||||||
@@ -353,7 +354,6 @@ export const parseKey = R.curry(
|
|||||||
_key = `${fieldKey}`;
|
_key = `${fieldKey}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(_key);
|
|
||||||
return _key;
|
return _key;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -432,13 +432,19 @@ export const sanitizeSheetData = (json) => {
|
|||||||
export const getMapToPath = (to: string, group = '') =>
|
export const getMapToPath = (to: string, group = '') =>
|
||||||
group ? `${group}.${to}` : to;
|
group ? `${group}.${to}` : to;
|
||||||
|
|
||||||
|
export const getImportsStoragePath = () => {
|
||||||
|
return path.join(global.__storage_dir, `/imports`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the imported file from the storage and database.
|
* Deletes the imported file from the storage and database.
|
||||||
* @param {string} filename
|
* @param {string} filename
|
||||||
*/
|
*/
|
||||||
export const deleteImportFile = async (filename: string) => {
|
export const deleteImportFile = async (filename: string) => {
|
||||||
|
const filePath = getImportsStoragePath();
|
||||||
|
|
||||||
// Deletes the imported file.
|
// Deletes the imported file.
|
||||||
await fs.unlink(`public/imports/${filename}`);
|
await fs.unlink(`${filePath}/${filename}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,5 +453,7 @@ export const deleteImportFile = async (filename: string) => {
|
|||||||
* @returns {Promise<Buffer>}
|
* @returns {Promise<Buffer>}
|
||||||
*/
|
*/
|
||||||
export const readImportFile = (filename: string) => {
|
export const readImportFile = (filename: string) => {
|
||||||
return fs.readFile(`public/imports/${filename}`);
|
const filePath = getImportsStoragePath();
|
||||||
|
|
||||||
|
return fs.readFile(`${filePath}/${filename}`);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user