Using Content Channels to Import Files : Virtual Path null Exception

Vote:
 

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: virtualPath
   at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)
   at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)
   at EPiServer.ContentChannels.ContentChannelHandler.CreateFile(String channelId, UnifiedDirectory directory, String fileName, Guid fileId, Byte[] data, Boolean expectMoreData, IDictionary`2 metadata)
   at EPiServer.ContentChannels.ContentChannelHandler.ImportFile(String channelId, Byte[] data, Boolean expectMoreData, Guid fileId, String channelRelativeFilePath, IDictionary`2 metadata)
   at EPiServer.WebServices.ContentChannelService.ImportFile(String channelId, Byte[] data, Boolean expectMoreData, Guid fileId, String channelRelativeFilePath, String[] metadataKeys, String[] metadataValues)
   --- End of inner exception stack trace ---

I'm getting an exception when trying to import a page using content channels. 

My code, which is really straight-forward:

DirectoryInfo dirInfo = new DirectoryInfo(myLocalPath + myImagesFolder);

foreach (FileInfo file in dirInfo.GetFiles())
{
EPiServer.Content.ContentChannelService channelService = new EPiServer.Content.ContentChannelService();
byte[] rawData = File.ReadAllBytes(file.FullName);
channelService.ImportFile(ImporterSettings.ContentChannelName, rawData, false, "images/");
}

Has anyone had any experience with this? I've pasted the exception details below if it's of any relevance.

Thanks,
James

 

-------------------------------------------------------------------------

The exception details:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null.Parameter name: virtualPath   at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)   at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)   at EPiServer.ContentChannels.ContentChannelHandler.CreateFile(String channelId, UnifiedDirectory directory, String fileName, Guid fileId, Byte[] data, Boolean expectMoreData, IDictionary`2 metadata)   at EPiServer.ContentChannels.ContentChannelHandler.ImportFile(String channelId, Byte[] data, Boolean expectMoreData, Guid fileId, String channelRelativeFilePath, IDictionary`2 metadata)   at EPiServer.WebServices.ContentChannelService.ImportFile(String channelId, Byte[] data, Boolean expectMoreData, Guid fileId, String channelRelativeFilePath, String[] metadataKeys, String[] metadataValues)   --- End of inner exception stack trace ---

-------------------------------------------------------------------------

#40643
Jun 14, 2010 23:08
Vote:
 

Hello,

What VPP class have you mapped to the 'images' virtual directory. This can be found in web.config under:

<episerver xmlns="http://EPiServer.Configuration.EPiServerSection">

<virtualPath customFileSummary="~/FileSummary.config">

<providers>

<add virtualName="Images" type"............"

#40657
Jun 15, 2010 9:56
Vote:
 

Thanks for the reply.

I don't think I have to do that, do I? I set the root folder on the Content Channel configuration within the EPiServer Admin. My understanding is that the parameter 'channelRelativeFilePath' is for passing the name/path of sub-folder to use (or create if it doesn't exist) for the file you are importing. This path, as the name suggests, is channel relative so if my root (set in Admin) was "~/Global/Imported/" and I pass "Images/", my file will be imported into "~/Global/Imported/Images/".

Maybe I have this wrong, I would appreciate some input.

I have tried creating the Images folder within /Global/Imported/ but the same exception comes up when I run the import.

It seems you cannot pass an empty string either. You get a different exception - EPiServer.Core.EPiServerException: channelRelativeFilePath must be given.

Oh, and I am using EPiServer 6.0.

#40667
Jun 15, 2010 11:30
Vote:
 

OK. I've asked our support engineers to look into this for you.

Paul.

#40673
Jun 15, 2010 12:11
Vote:
 

Thanks a lot Paul!

#40675
Jun 15, 2010 12:15
Vote:
 

Hi again James.

 

Unfortunately I am told you will need to register a support case here:

http://world.episerver.com/Support/Register-Support-Incident/

 

Regards

Paul

#40676
Jun 15, 2010 12:45
Vote:
 

Right, that's it sent.

I selected that it's a CMS 6.0 issue but my case is listed within an inbox named CMS 5 under my EPiDesk account. Strange.

Thanks again, Paul.

Cheers,
James

#40684
Jun 15, 2010 15:07
Vote:
 

Hi James,
The RelativePath parameter must include file name,
so channelService.ImportFile(ImporterSettings.ContentChannelName, rawData, false, "images/");
should be channelService.ImportFile(ImporterSettings.ContentChannelName, rawData, false, "images/filename");

 

#40784
Jun 17, 2010 6:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.