Example #1
0
        public static bool UploadImg(byte[] imgContent, string fileExtension)
        {
            Contract.Assert(imgContent != null);
            Contract.Assert(imgContent.Length > 0);
            Contract.Assert(!String.IsNullOrWhiteSpace(fileExtension));

            IntPtr unmanagedBuffer = IntPtr.Zero;

            try
            {
                unmanagedBuffer = Marshal.AllocCoTaskMem(imgContent.Length);
                Marshal.Copy(imgContent, 0, unmanagedBuffer, imgContent.Length);
                var rawImg = new structs.RawImg()
                {
                    content       = unmanagedBuffer,
                    contentSize   = (UInt32)imgContent.Length,
                    fileExtension = fileExtension
                };
                var result = new structs.UploadImgResult();
                UploadImg(rawImg, out result);

                return(result.opStatus == 0);
            }
            finally
            {
                if (unmanagedBuffer != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(unmanagedBuffer);
                }
            }
        }
Example #2
0
 private static extern void UploadImg(structs.RawImg img, out structs.UploadImgResult result);