I’m uploading a excel file to be processed by a function, but can’t find the correct server location on the cloud. Thanks to Hannah, the upload was no problem and I can see the file on the server using the server file download.
When I try to access the file using Erp.Internal.Lib.ExcelReader I get a file not found error. Guess and check hasn’t gotten me anywhere except I figured out the server folder is on the f drive and \ServerName\Epicordata gives a permission error.
Both the company path and user path come back empty when using Ice.Contracts.ServerPathSvcContract.
CallService<Ice.Contracts.ServerPathSvcContract>(serverPathSvc =>
{
var userPath = ((Ice.Contracts.ServerPathSvcContract)serverPathSvc).GetPaths(Epicor.ServiceModel.Utilities.SpecialFolder.UserData, "", false);
var companyPath = ((Ice.Contracts.ServerPathSvcContract)serverPathSvc).GetPaths(Epicor.ServiceModel.Utilities.SpecialFolder.CompanyData, "", false);
});
The files are in sub folders based on an ECO Group under both the company and user. (I’ve uploaded them both places and confirmed the files are there by downloading them)
I’ve tried:
F:\EpicorData\Companies{CompanyID}{ECOGroupID}{FIleName}
F:\EpicorData\Users{UserID}{ECOGroupID}{FIleName}
If I don’t put a drive letter in it defaults to the F drive and if I don’t put a path in at all it defaults to the inetpub server folder on the F drive.
When I drop a file to the server using REST I denote the folder as an integer. I believe the Company folder is 5 and the user folder is 4. If I enter this using Ice.LIB.FileTransferSvc FileExists, it returns true.
I’ve kicked out the results of ServerPathSvc with include files set to true. I can see my files in both the user and company folder, but the FullName doesn’t include the full path.
It returns
“FullName”: “CWR\BOMGEN022404025MHS_Model.xls”
for both the User and Company folders. (The file is in both locations)
I found the file it’s located at
F:\EpicorData\{TenantID}\{TenantID}\Companies\{CurrentComany}\{Folder}\{File}
(Yes two TenantID folders)
I had my mind set on finding the file since I was planning on using the ExcelReader.
using (var excelReader = new Erp.Internal.Lib.ExcelReader(fullPath))
{
var workSheets = excelReader.WorksheetNames;
}
I was able to read the sheet names using the ExcelReader, but I think I will switch over to the byte array and use DocumentFormat.OpenXml. Using the service to read the file seems much less likely to break than
F:\EpicorData\{TenantID}\{TenantID}\Companies\{CurrentComany}\{Folder}\{File}
Thanks for everyone’s help. I successfully created function that reads an excel file that was uploaded to the server and returns the contents in a data set. This works in the cloud.
This worked because passing false as the third method parameter said - I don’t want the file names, just the directory which returned a collection where the first element represented the parent directory.
However, this logic was changed somewhere between 2023.2.11 and 2024.2.7 to now return an empty string only. You can still obtain the same absolute path using this lib helper:
As @klincecum mentioned, you probably don’t need this pathway directly just for uploading / downloading files unless you are using a separate embedded program files that require it, such as Aspose PDF. I wanted to include this information for completeness when people search to this post and find a reference to ServerPathSvcContract for the purposes mentioned.