Docx recognised as zip

So when I upload a docx file with metadata and properties like author etc, it detects the file as a zip, which in turn makes any removal of metadata or properties impossible…

using (Metadata metadata = new(newFile))
metadata.FileFormat //This is zip?

Tried the same with uploading a pdf, and it says its a mp3? Is there something wrong with reading from a stream instead of a file?

I tried loading a local file instead and it says fileformat unknown… Is it that the project is net 6 and its not supported?

I even set up at net 2.1 project, strange that you dont support any viable .net core? But I still get the same kind of errors…

1 Like

@jesper.dittberner

Please share following details and we’ll look into this issue:

  • Sample code using that issue could be reproduced
  • API version (e.g. 20.10, 21.8)
  • Operating system details (e.g. version)
  • Problematic/source file(s)

Hi Atir_Tahir,

API: 21.8.0
Operating system: Windows 10 x64
Included two sample files, but any would do really…samplepng.PNG (15.6 KB)
testwordfile.docx (11.7 KB)

Sample code:
var appDomain = System.AppDomain.CurrentDomain;
var basePath = appDomain.RelativeSearchPath ?? appDomain.BaseDirectory;
var docpath = Path.Combine(basePath, “License”, “GroupDocs.Metadata.NET.lic”);
using (FileStream fileStream = new FileStream(docpath, FileMode.Open, FileAccess.Read))
{
License lic = new License();
lic.SetLicense(fileStream);
}
var filepath = Path.Combine(basePath, “Templates”, “testwordfile.docx”); // Shows as ZIP
var filepath = Path.Combine(basePath, “Templates”, “samplepng.PNG”); // Shows as MP3
using (Metadata metadata = new Metadata(filepath))
{
if (metadata.FileFormat != GroupDocs.Metadata.Common.FileFormat.Unknown && !metadata.GetDocumentInfo().IsEncrypted)
{
var affected = metadata.Sanitize();
metadata.Save();
}
}

@jesper.dittberner

Please share a simple console application using that issue could be reproduced. We created a new .NET Core 2.1 application, processed the image (PNG) you shared and metadata.FileFormat shows PNG.

I created a console application aswell and it worked fine. I created a class library with 2.1 and did the cleaning in that, shouldnt that work in the same way? Or does it matter that the main project that is running the application is .NET 6?

When I changed the console application to 6.0, it displayed the same issues, so it seems the target framework is the issue here.

Is there a way to use this in a .NET 6 project? I thought by changing the class library to 2.1 it would work…

@jesper.dittberner

We are investigating this issue. Your investigation ticket ID is METADATANET-3944.

Hi Atir,

Is there any update on making this compatible with .net core?

@jesper.dittberner

This ticket is still under investigation.

@jesper.dittberner

In .NET Core 2.1, 3.1, 5.0, the provided DOCX file is defined as WordProcessing. In .NET 6.0 it is defined as Zip. The PNG file is also not correctly defined in .NET 6.0 (Unknown).
However, we will continue the investigation and let you know as there’s any update.

The issues you have found earlier (filed as METADATANET-3944) have been fixed in this update. This message was posted using Bugs notification tool by Atir_Tahir