U4-6743 - Can't upload image without _thumb access error claiming its in use by another process.

Created by Tim Brooks 23 Jun 2015, 01:11:44 Updated by Claus Jensen 04 Apr 2017, 07:50:08

The process cannot access the file 'C:\Dev\iMediaCorporate\Trunk\source\iMediaCorporate.Web\media\856672\img0035_thumb.jpg' because it is being used by another process.

I'm on the latest version 7.2.6. I updated today after reading about some similar issues hoping it would help. The issue is not consistent, meaning it will happen each time I try a batch of images, but not always on the same file. Stepping through seemed to work better, but it would still fail after 10 or so tries vs on the first one.

Calling Code

        var ms = UmbracoContext.Current.Application.Services.MediaService;
        var basePath = @"C:\Temp\30131\"; 
                       // "C:\Dev\iMediaCorporate\Trunk\source\iMediaCorporate.Web";
        var folderPath = "";//@"/images/ImportedSummitGalleries/" + imageFolder+"/"; 

        //get all the files in the folder
        var files = System.IO.Directory.GetFiles(basePath+folderPath);


        foreach (var file in files.OrderBy(x => x))
        {
            var fileName = file.Split('\\').Last();
            var newMedia = ms.CreateMedia(fileName, nodeId, "Image");

            byte[] buffer = System.IO.File.ReadAllBytes(file);
            var strm = new MemoryStream(buffer);
            newMedia.SetValue("umbracoFile",fileName, strm );
            ms.Save(newMedia);
        }

Stack Trace and Error [IOException: The process cannot access the file 'C:\Dev\iMediaCorporate\Trunk\source\iMediaCorporate.Web\media\856672\img0035_thumb.jpg' because it is being used by another process.] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +14584403 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1430 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +208 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +90 System.IO.File.Create(String path) +64 Umbraco.Core.IO.PhysicalFileSystem.AddFile(String path, Stream stream, Boolean overrideIfExists) +393 Umbraco.Core.IO.PhysicalFileSystem.AddFile(String path, Stream stream) +63 Umbraco.Core.IO.FileSystemWrapper.AddFile(String path, Stream stream) +101 Umbraco.Core.Media.ImageHelper.GenerateThumbnail(Image image, Int32 maxWidthHeight, Int32 fixedWidth, Int32 fixedHeight, String thumbnailFileName, String extension, IFileSystem fs) +2700 Umbraco.Core.Media.ImageHelper.GenerateThumbnail(Image image, Int32 maxWidthHeight, String thumbnailFileName, String extension, IFileSystem fs) +103 Umbraco.Core.Media.ImageHelper.Resize(IFileSystem fileSystem, String path, String extension, Int32 maxWidthHeight, String fileNameAddition, Image originalImage) +437 Umbraco.Core.Media.ImageHelper.GenerateMediaThumbnails(IFileSystem fs, String fileName, String extension, Image originalImage, IEnumerable`1 additionalThumbSizes) +1401 Umbraco.Core.Models.ContentExtensions.SetFileOnContent(IContentBase content, String propertyTypeAlias, String filename, Stream fileStream) +2713 Umbraco.Core.Models.ContentExtensions.SetValue(IContentBase content, String propertyTypeAlias, String fileName, Stream fileStream) +135 iMediaCorporate.Web.Controllers.RedDotImportController.ImportSummitImages(String imageFolder, Int32 nodeId) in c:\Dev\iMediaCorporate\Trunk\source\iMediaCorporate.Web\Controllers\RedDotImportController.cs:1641

1 Attachments

Download 124 - 30131.zip

Comments

Tim Brooks 23 Jun 2015, 15:45:49

sorry - latest is 7.2.6 and that's the version I just updated too. I've attached a sample batch of images that I was using when the error occurred. Not always on the same photo but each time this batch was run it would fail.


Claus Jensen 04 Apr 2017, 07:50:05

Thumbnails generation has been removed in 7.6 so will close this issue for now.


Priority: Normal

Type: Bug

State: Closed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version:

Sprint:

Story Points:

Cycle: