Webservice File.Exist

NoiK00NoiK00 Member Posts: 51
edited 2013-09-30 in NAV Three Tier
Hi all,

When running a webservices and trying to open a file i get the error "Access Denied".

Here's the things i tried:
- Local paths works(see the tried paths and results in the code);
- I've already checked the permissions, looked fine;
- I've logged in using the same user on the server and tried to acces the file myself, it worked;
- Tested if it was a long path name, small path names also didn't work;
- Tried working with absolute pathnames, no difference;
- As an alternative i tried to just open the file instead of checking if it exists, with no result.

This is the used code:
GetProductImage(productid : Code[10];VAR data : BigText)
IF NOT (productid = '') THEN
  IF (item.GET(productid) AND (item."Picture Name" <> '')) THEN
  BEGIN
    //Get default settings
    RecSalesSetup.GET;
    RecSalesSetup.TESTFIELD("Path Item Pictures-WEB");

    test := USERID;
  
    IF test = '' THEN
      ERROR('Ghost user!');

  //  LocTxtPicture := '\\server07\c$\75000 (Custom).jpg'; //Joy, local
  //  LocTxtPicture := 'c:\75000 (Custom).jpg'; //joy, local
  //  LocTxtPicture := RecSalesSetup."Path Item Pictures-WEB" + item."Picture Name" + '.jpg'; //No joy
    LocTxtPicture := '\\server04\data\itemadministration\Web\75000 (Custom).jpg'; //No joy
//    LocTxtPicture := '\\172.19.1.203\data\itemadministration\Web\75000 (Custom).jpg';  //No joy
//    LocTxtPicture := '\\172.19.1.203\data\itemadministration\75000 (Custom).jpg';  //No joy
//    LocTxtPicture := '\\172.19.1.203\data\75000 (Custom).jpg';  //No joy

    FileHelper2 := FileHelper2.FileInfo(LocTxtPicture);  //'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileInfo
    FileMode := 4;
    FileHelper.Open(LocTxtPicture, FileMode); //'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File

    IF (FileHelper.ToString()) <> '' THEN
     //FileHelper2.Exists THEN //FileHelper.Exists(LocTxtPicture) THEN//AND FileHelper2.Exists THEN
    BEGIN
      picture.CREATEINSTREAM(IStream);
      picture.OPEN(LocTxtPicture);

      IF picture.LEN > 0 THEN picture.CREATEINSTREAM(IStream);
      MemoryStream := MemoryStream.MemoryStream();
      COPYSTREAM(MemoryStream, IStream);
      Bytes := MemoryStream.GetBuffer();
      data.ADDTEXT(Convert.ToBase64String(Bytes));
      picture.CLOSE;
    END
    ELSE
      ERROR('File Not Found');
  END
  ELSE
    ERROR('No File')
ELSE
  ERROR('No ID');

Any suggestions on what to do to get it working?

Thanx,
NoiK

EDIT: the server is running the servicetier AND SQL database
AND the user is a domain admin account
Sign In or Register to comment.