Question

A sitecore instance was recently upgraded from 6.1 to 6.6. There was an upload command that opened a custom xaml dialog. This had an upload button on it which would open another modal with:

UploadPackageForm.Show(MyConstants.FolderPath, true);

While testing some points of functionality across the site I ran into an error while using this uploader saying that the file being uploaded needs to be a zip file. I'm guessing that somewhere along the way from 6.1 to 6.6 the package uploader was given a check for the file type being uploaded. I've been looking around for dialogs that sitecore comes with that I may be able to use. These look promising:

I can't seem to get the file path from this one although I think I could set a property on args passed into the OnOK event which I will try tomorrow.

Sitecore.Shell.Applications.Install.Dialogs.AddFilesDialog

I'm not sure how I would show this one:

Sitecore.Shell.Applications.Dialogs.Upload

Another option is to try making a custom dialog. Any thoughts and ideas are appreciated.

Was it helpful?

Solution

I had a look around the code that deals with the file explorer (that does not restrict the upload file type) and found this. Might be useful:

public static void UploadToDirectory(string directory)
{
  Assert.ArgumentNotNull((object) directory, "directory");
  Error.AssertString(directory, "directory", true);
  UrlString urlString = new UrlString("/sitecore/shell/Applications/Dialogs/Upload/Upload.aspx");
  urlString.Append("di", directory);
  Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "files:uploaded");
}

This method is in Sitecore.Shell.Framework.Files in Sitecore.Kernel

OTHER TIPS

Is the upload for site visitors or Sitecore users within a Sitecore app? Regardless, the UploadPackageForm, in 6.6, validates that the file is a valid Sitecore package (which is always a ZIP file). 6.1 didn't do this.

DOn't use the AddFilesDialog as that's also within the context of installing a Sitecore app.

I'm not exactly sure what the upload is for but if it's for the rendered site, you should create your own. If it's for a Sitecore app, there are several depending on what you need. There's the FlashUpload (3 types under /sitecore/shell/Applications/FlasUpload), the Media uploads at /sitecore/shell/Applications/Media/Upload****.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top