We are trying to upload zip files to AGOL. If I was doing in AGOL I would create the item, define it as a Code Sample (which will allow a generic zip file).
Hoped we could do this in Runtime (100.15). I see this old thread How to create a new FeatureService PortalItem which seems to indicate only saving Maps is supported, but it is 3 years old so would hope that is no longer the case.
Seems pretty simple:
ZipFile.CreateFromDirectory(projectItem.MapPackagePath, outputfile);
var portalItem = new PortalItem(portal, PortalItemType.CodeSample, projectItem.Title);
using ( var fileStream = File.OpenRead(outputfile) )
{
await portalItem.UpdateDataAsync(fileStream);
}
await portal.User.AddPortalItemAsync(portalItem);
await portalItem.ShareWithGroupsAsync(new[] { group });
Couple problems occur.
- It requires that the user re-enter credentials on the call to new PortalItem even though authenticated
- The primary issue: it never returns from the await portalItem.UpdateDataAsync. It just hangs and so cannot ever put the item in AGOL
Is what I need to do supported? If so what would be a correct way to do this
Thanks - Joe