mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
parent
2983e657a6
commit
ec79069a1c
1 changed files with 10 additions and 19 deletions
|
@ -58,24 +58,15 @@ localfilesystem = {
|
|||
|
||||
getUniqueFileName(target_dir, basename, ext, null, function (filename) {
|
||||
|
||||
fs.mkdirs(target_dir, function (err) {
|
||||
if (err) {
|
||||
errors.logError(err);
|
||||
return saved.reject();
|
||||
}
|
||||
|
||||
fs.copy(image.path, target_path, function (err) {
|
||||
if (err) {
|
||||
errors.logError(err);
|
||||
return saved.reject();
|
||||
}
|
||||
|
||||
// NOTE as every upload will need to delete the tmp file make this the admin controllers job
|
||||
|
||||
// The src for the image must be in URI format, not a file system path, which in Windows uses \
|
||||
var fullUrl = path.join(ghostUrl, filename).replace(new RegExp('\\' + path.sep, 'g'), '/');
|
||||
return saved.resolve(fullUrl);
|
||||
});
|
||||
nodefn.call(fs.mkdirs, target_dir).then(function () {
|
||||
return nodefn.call(fs.copy, image.path, target_path);
|
||||
}).then(function () {
|
||||
// The src for the image must be in URI format, not a file system path, which in Windows uses \
|
||||
var fullUrl = path.join(ghostUrl, filename).replace(new RegExp('\\' + path.sep, 'g'), '/');
|
||||
return saved.resolve(fullUrl);
|
||||
}).otherwise(function (e) {
|
||||
errors.logError(e);
|
||||
return saved.reject(e);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -83,4 +74,4 @@ localfilesystem = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = localfilesystem;
|
||||
module.exports = localfilesystem;
|
||||
|
|
Loading…
Add table
Reference in a new issue