This works great. Node is removing from the database as expected. No problems. However, noticed some worrying behaviour. When this code is executed a folder (containing images) within .\media...\london.. is also magically removed. The node being removed is pretty standard, afew props - image, text fields and a textarea.
Can anyone explain why that code is not just confined to the task at hand (removing the node from the cms) but also removing a file system folder? Been scratching my head, debugging, the folder goes at the point that delete method is called.
Is there a safer / better way to perform a deletion of a node in umbraco7?
Hi Dave, thanks for reply. The data type on this particular doc type is the standard file-upload (which displays a preview of the image). I worked on feature to be able to remove this doc type in code, but realised the parent folder of the image (which lives under ./media) was also vanishing - meaning all other images in that folder would go. Luckily this all local dev stuff - but really scratching my head to figure out how a very standard contentservice...delete(contentitem) is taking that image parent folder with it (off the file system) ....... any other thoughts?
I didn't check the source do but this is what I suspect why this is happening.
When you use a file upload property the uploaded file is not available as an item in the umbraco media library. The file itself however is stored in the media folder.
So when you delete a content item, is deleted the file is deleted as well because it can not be reused in Umbraco. Seems to m as expected behavior because otherwise it will leave your media folder with a lot of files that are not used anymore.
Ok I see. Yes that would make sense. These are images but not media library items. I think there was a reason I needed to add the folder under ‘media’ (maybe to see the thumbnail in back office).
2 options. I actually don’t need that file upload data type on the item. Can remove it and see how that goes. Even better still going forward - can try moving these up and out and into a different folder, away from media.
will return
"ExceptionMessage": "File '/images/folder/IMG_1234.JPG' is outside this filesystem's root.",
"ExceptionType": "Umbraco.Core.IO.FileSecurityException",
"StackTrace": " at Umbraco.Core.IO.PhysicalFileSystem.GetFullPath(String path)\r\n at Umbraco.Core.IO.PhysicalFileSystem.GetLastModified(String path)\r\n at Umbraco.Web.Editors.ImagesController.GetResized(String imagePath, Int32 width, String sizeName) .........
Before I start digging in to this stack trace / exception I thought you might know what this ? and if / how it is possible to enable folders to return images outside the media folder (config?).
Umbraco7 contentservice delete contentitem
Hi.
I am using the content service to remove a content item -
This works great. Node is removing from the database as expected. No problems. However, noticed some worrying behaviour. When this code is executed a folder (containing images) within .\media...\london.. is also magically removed. The node being removed is pretty standard, afew props - image, text fields and a textarea.
Can anyone explain why that code is not just confined to the task at hand (removing the node from the cms) but also removing a file system folder? Been scratching my head, debugging, the folder goes at the point that delete method is called.
Is there a safer / better way to perform a deletion of a node in umbraco7?
Thanks
Hi Matthew,
Is your Image property a upload of image cropper datype ? Then that could be the cause.
Dave
Hi Dave, thanks for reply. The data type on this particular doc type is the standard file-upload (which displays a preview of the image). I worked on feature to be able to remove this doc type in code, but realised the parent folder of the image (which lives under ./media) was also vanishing - meaning all other images in that folder would go. Luckily this all local dev stuff - but really scratching my head to figure out how a very standard contentservice...delete(contentitem) is taking that image parent folder with it (off the file system) ....... any other thoughts?
Hi Matthew,
I didn't check the source do but this is what I suspect why this is happening.
When you use a file upload property the uploaded file is not available as an item in the umbraco media library. The file itself however is stored in the media folder.
So when you delete a content item, is deleted the file is deleted as well because it can not be reused in Umbraco. Seems to m as expected behavior because otherwise it will leave your media folder with a lot of files that are not used anymore.
Dave
Dave,
Ok I see. Yes that would make sense. These are images but not media library items. I think there was a reason I needed to add the folder under ‘media’ (maybe to see the thumbnail in back office).
2 options. I actually don’t need that file upload data type on the item. Can remove it and see how that goes. Even better still going forward - can try moving these up and out and into a different folder, away from media.
Hi Dave, If I try and move those images out the media folder they are not rendered in back office (in that file upload data type).
Example - this path .... http://...../umbraco/backoffice/UmbracoApi/Images/GetBigThumbnail?originalImagePath=/images/folder/IMG_1234.JPG
will return "ExceptionMessage": "File '/images/folder/IMG_1234.JPG' is outside this filesystem's root.", "ExceptionType": "Umbraco.Core.IO.FileSecurityException", "StackTrace": " at Umbraco.Core.IO.PhysicalFileSystem.GetFullPath(String path)\r\n at Umbraco.Core.IO.PhysicalFileSystem.GetLastModified(String path)\r\n at Umbraco.Web.Editors.ImagesController.GetResized(String imagePath, Int32 width, String sizeName) .........
whereas http://...../umbraco/backoffice/UmbracoApi/Images/GetBigThumbnail?originalImagePath=/media/folder/IMG_1234.JPG
returns the image fine.
Before I start digging in to this stack trace / exception I thought you might know what this ? and if / how it is possible to enable folders to return images outside the media folder (config?).
Hi Matthew,
Maybe a stupid question...but why you want to save your files in another location ?
Is there any special requirement for that ?
Dave
is working on a reply...