Open Closed

FileManager won't create file when no ExtensibleObject is passed #3116


User avatar
0
cezary.bojko created
  • ABP Framework version: v5.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
at Volo.Abp.Check.NotNull[T](T value, String parameterName)
   at Volo.Abp.ObjectExtending.ExtensibleObjectMapper.MapExtraPropertiesTo[TSource,TDestination](TSource source, TDestination destination, Nullable`1 definitionChecks, String[] ignoredProperties)
   at Volo.Abp.ObjectExtending.HasExtraPropertiesObjectExtendingExtensions.MapExtraPropertiesTo[TSource,TDestination](TSource source, TDestination destination, Nullable`1 definitionChecks, String[] ignoredProperties)
   at Volo.FileManagement.Files.FileManager.<SaveFileDescriptorAsync>d__12.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Volo.FileManagement.Files.FileManager.&lt;CreateAsync&gt;d__11.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
  • Steps to reproduce the issue:"

After update from 5.1.4 to 5.2.2 I must pass optional parameter (extensibleObject) to avoid exception.

        await _fileManager.CreateAsync(errorFileName, "text/plain", new RemoteStreamContent(stream), directoryId, extensibleObject: new ExtensibleObject());

4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will check this.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Please try to override the SaveFileDescriptorAsync of Volo.FileManagement.Files.FileManager service

    protected override async Task<FileDescriptor> SaveFileDescriptorAsync(string name, string mimeType, int contentLength, Guid? directoryId, Guid? tenantId, bool overrideExisting, ExtensibleObject extensibleObject = null)
    {
        var fileDescriptor = await FileDescriptorRepository.FindAsync(name, directoryId);
    
        if (fileDescriptor != null)
        {
            if (!overrideExisting)
            {
                throw new FileAlreadyExistException(name);
            }
    
            fileDescriptor.Size = contentLength;
            extensibleObject?.MapExtraPropertiesTo(fileDescriptor);
            await FileDescriptorRepository.UpdateAsync(fileDescriptor);
        }
        else
        {
            fileDescriptor =
                new FileDescriptor(GuidGenerator.Create(), name, mimeType, directoryId, contentLength, tenantId);
            extensibleObject?.MapExtraPropertiesTo(fileDescriptor);
            await FileDescriptorRepository.InsertAsync(fileDescriptor);
        }
    
        return fileDescriptor;
    }
    
  • User Avatar
    0
    cezary.bojko created

    So, is this a bug? Could I get question refund?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Refunded : )

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11