locked
HTTP upload of file to MountPoint on CF returns a 403 error RRS feed

  • Question

  • I can download a file from the CF Mountpoint, I can communicate with the services via HTTP and the same code works on the PC version. However when I try to upload a file to the mount point it returns a 403 error. Security has been disabled.

    Some more information. It appears that an exception is being thrown in the HTTPPut handler. Also the mount operations seem to work, update and replace on the mount point operations both work.

     

    Any known bug here?

    Monday, October 18, 2010 9:57 PM

Answers

  • Trevor,

    The mount point update and replace really don't work for my application.

    From a design perspective:

    We are implementing the DSSP protocol in C++ so I'm looking to have a clean RESTful behavior for transferring files to make it easy to have a wire compatible protocol implementation. We aren't using dssp.tcp but have agreed to use dssp over http for all wire communication (in this particular area). I also what to be able to tranfer a file from a Silverlight client. I can do a HTTPPut from Silverlight but not so sure on sending a Update to the mountpoint.

    From a implementation prespective:

    What I need to stream isn't used by my code but is consumed by another application which the DSS is managing. The mountpoint Update is not equivalent because it encodes the data stream as Base64, this becomes an issue when the data transferred becomes large. I assume this would be an issue for replace as well. Update isn't a file transfer mechanism but more of a data transfer. If the file I'm transferring already exists before I use the mountpoint Update it can write only a portion of the file is written causing file corruption. Trying to use the DsspDefaultReplace takes an object and I haven't been able to figure out how to stream a byte[] as an object. The files I'm trying to transfer can be in the 1-2 MB size range so I don't want to allocate the entire byte[] and transfer as a whole. This impacts the CF much more than the PC as it must allocate this entire buffer before streaming to flash.

    I do really need to get HttpPut working. I'm pursuing this through our MSDN support so maybe that would be a better way to handle this? There is a lot to like about the DSS, especially for CF.

     

    Mike

     

    Tuesday, November 16, 2010 4:51 AM

All replies

  • I know that the call is being made and the file is created which I can see in the file manager but is failing when the stream is trying to be read. Using reflection on the mountpoint it looks like the call is failing in ReadRequestToStream and throwing an exception which gets caught and returned as a 403 error

    string localPath = uri.LocalPath;
    string directoryName = Path.GetDirectoryName(localPath);
    fExists = false;
    if (!Directory.Exists(directoryName))
    {
          Directory.CreateDirectory(directoryName);
    }
    else
    {
         fExists = File.Exists(localPath);
    }
    fStream = new FileStream(localPath, FileMode.Create, FileAccess.Write, FileShare.Read, this._fileStreamBufSizeHTTP, true);
    ReadRequestToStream stream = new ReadRequestToStream(msg.Body.Context, fStream);
    

    After doing some logging it looks like the exception is occuring in Stream.BeginRead and that CanRead is false throwing a NotSupportedException

    public virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)

    {

    if (!this.CanRead)
        {
            __Error.ReadNotSupported(); << Throws
        }

    ...

    However the HttpRequestStream which calls beginread had the CanRead set to true. So why is this throwing? Is it possible that _realStream is not getting setup?

    I added a httpput into another service and it can be called with the same data so I'm at a loss as to why MountPoint is failing.

    I really need to be able to transfer binary files via HTTP to a WinCE device. This should work right??

    • Edited by CognexMike Tuesday, October 19, 2010 6:41 PM More info
    Tuesday, October 19, 2010 5:18 PM
  • This also happens if you just startup cf.dsshost and try to do a HttpPut to the mountservice.
    Tuesday, October 19, 2010 10:19 PM
  • Thanks for the feedback. I will have to get a developer to look at it.

    Trevor

     

    Thursday, November 4, 2010 5:57 AM
  • Mike,

    You say that Update and Replace work. Doing a Replace DSSP operation over HTTP should be equivalent to a HttpPut. Can you confirm that this works for you?

    Trevor

     

    Tuesday, November 16, 2010 3:15 AM
  • Trevor,

    The mount point update and replace really don't work for my application.

    From a design perspective:

    We are implementing the DSSP protocol in C++ so I'm looking to have a clean RESTful behavior for transferring files to make it easy to have a wire compatible protocol implementation. We aren't using dssp.tcp but have agreed to use dssp over http for all wire communication (in this particular area). I also what to be able to tranfer a file from a Silverlight client. I can do a HTTPPut from Silverlight but not so sure on sending a Update to the mountpoint.

    From a implementation prespective:

    What I need to stream isn't used by my code but is consumed by another application which the DSS is managing. The mountpoint Update is not equivalent because it encodes the data stream as Base64, this becomes an issue when the data transferred becomes large. I assume this would be an issue for replace as well. Update isn't a file transfer mechanism but more of a data transfer. If the file I'm transferring already exists before I use the mountpoint Update it can write only a portion of the file is written causing file corruption. Trying to use the DsspDefaultReplace takes an object and I haven't been able to figure out how to stream a byte[] as an object. The files I'm trying to transfer can be in the 1-2 MB size range so I don't want to allocate the entire byte[] and transfer as a whole. This impacts the CF much more than the PC as it must allocate this entire buffer before streaming to flash.

    I do really need to get HttpPut working. I'm pursuing this through our MSDN support so maybe that would be a better way to handle this? There is a lot to like about the DSS, especially for CF.

     

    Mike

     

    Tuesday, November 16, 2010 4:51 AM