Amazon-SP-API-CSharp icon indicating copy to clipboard operation
Amazon-SP-API-CSharp copied to clipboard

SubmitFeedAsync doesn't handle XML as file (and files are fully loaded to memory)

Open tank104 opened this issue 3 years ago • 2 comments

Hi, SubmitFeedAsync doesn't check whether the xmlContentOrFilePath is file path, so XML content always needs to be loaded into memory as a string (and then converted to byte array, so really loads in memory twice). Is this by design?

Ideally we want a way to specify whether its a file, and also change PostFileDataAsync to write from file to stream. Otherwise for very large files a large amount of memory is consumed.

I am happy to do a PR for this - just want to know how best to apprach it?


            if (contentType == ContentType.PDF)
            {
                _ = await PostFileDataAsync(feedCreate.Url, XmlContentOrFilePath, contentType);
            }
            else if (contentType == ContentType.JSON)
            {
                _ = await PostFileDataAsync(feedCreate.Url, XmlContentOrFilePath, contentType);
            }
            else if (contentType == ContentType.TXT)
            {
                _ = await PostFileDataAsync(feedCreate.Url, XmlContentOrFilePath, contentType);
            }
            else
            {
                _ = await PostXMLDataAsync(feedCreate.Url, XmlContentOrFilePath);
            }

tank104 avatar Oct 02 '22 23:10 tank104

You Idea is good just write the code and test it then submit PR and i will review it and approve @tank104 Thanks in Advance

abuzuhri avatar Oct 06 '22 15:10 abuzuhri

Will do this week

tank104 avatar Oct 09 '22 22:10 tank104

Sorry for delay - my thoughts on how to achieve this are here: https://github.com/abuzuhri/Amazon-SP-API-CSharp/pull/401

Haven't fully tested it yet but was keen on your feedback?

tank104 avatar Nov 14 '22 01:11 tank104