Click here to Skip to main content
15,889,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing a mobile application in which the user can upload images, so the client is sending to the server the image uploaded through HTTP, so me as server side I'm catching the data parameters in the HTTP header using the following method...

but i just need to see if there is a faster or a better way to get the upload image

thank you in advance for your advice...

VB
rbi.logFile("upload=======start")

   Dim regID As Integer
   Dim from_id As String = ""
   Dim Filename As String = ""
   Dim FileExtension As String = ""
   Dim type As String = ""
   Dim FilePath As String = ""
   Dim ThumbnailsPath As String = ""
   Dim SavedFilename As String = ""
   Dim msg As String = ""
   Dim size As String = ""

   Dim ImagesExt As String = conf.getXmlConfig("IMAGESEXTENSIONS").ToUpper

   Try
       'get header parameters
       regID = Request.Headers.Get("MSG")
       msg = Request.Headers.Get("MSG")
       type = Request.Headers.Get("TYPE")

       'for android users
       If type = "3" Then
           msg = System.Web.HttpUtility.UrlDecode(msg)
       End If

       'from server to server

       'Dim PARAM As String = "IMEI=" & imei & "&IMSI=" & imsi
       'Dim url As String = "http://api.storenshare.co/GETID.aspx?" & PARAM

       'rbi.logFile("upload=======" & url)

       'Dim data As String = c.ReadHtmlPage(url, imei & "]" & imsi)
       'Dim StringValue As String() = data.Split("]")
       'rbi.logFile("upload=======data===" & data)
       'from_id = Trim(StringValue(0))
       'from_mo = Trim(StringValue(1))

       'get favortie ids to share

       Dim TOIDS As String = Request.Headers.Get("TOID")
       rbi.logFile("upload=======TOIDS===" & TOIDS)
       Filename = Request.Headers.Get("FileName")
       rbi.logFile("upload=======filename===" & Filename)
       '  FileExtension = Request.Headers.Get("EXT")
       type = Request.Headers.Get("TYPE")
       size = Request.Headers.Get("size")


       'get the image
       Dim str As System.IO.Stream
       str = Request.InputStream
       Dim strLen As Integer
       strLen = CInt(str.Length)
       Dim strArray(strLen) As Byte
       str.Read(strArray, 0, strLen)
       str.Close()
       If IsNothing(str) = False Then
           str.Dispose()
       End If
       If strArray.Length < 2 Then
           Session("return") = "-1"
           'Response.Write(Session("return"))
           Exit Sub
       End If
       size = strArray.Length

       Dim downloadpath As String = ""
       ' Dim downloadlink As String = "https://share.storenshare.co/folders" & "/" & from_id & "/Files/"

       'save image in a specific path

       FilePath = conf.getXmlConfig("USERSFOLDER") & "\" & from_id & "\Files\"
       Dim linkpath2 As String = conf.getXmlConfig("linkfolder") & "/" & from_id & "/Files/"

       Dim linkpath As String = "E:\STORE_FILES" & "\" & from_id & "\Files\"
       ThumbnailsPath = "E:\STORE_FILES" & "\" & from_id & "\thumbs\"
       Dim szThumbsFlag As String = "0"


       Session("return") = conf.WriteToFileByte(from_id, Filename, strArray, FilePath, SavedFilename, FileExtension)

       downloadpath = linkpath & SavedFilename & FileExtension
       If ImagesExt.IndexOf("|" & FileExtension.ToUpper & "|") > -1 Then
           Try
               ThumbnailsPath = linkpath & "thumbnails\" & SavedFilename & FileExtension

               If Not conf.generateThumbnail(linkpath, linkpath & "thumbnails\", SavedFilename & FileExtension) Then
                   rbi.logFile("generateThumbnail========" & "not thumb")
               End If
           Catch
               Session("return") = "-1"
           Finally
           End Try

       End If

       'database code

       'Dim requestvar As String = from_id & "]" & TOIDS & "]" & Filename & "]" & FileExtension & "]" & downloadpath & "]" & size & "]" & from_mo & "]" & msg & "]" & ThumbnailsPath
       'url = "http://api.storenshare.co/file_upload.aspx"
       'Data = c.ReadHtmlPage(url, requestvar)
       'Session("return") = Data

   Catch ex As Exception
       Session("return") = ("-1")
       rbi.logFile("upload====EXCEPTION====" & ex.ToString)
   Finally
       rbi.logFile("upload=======response=====" & Session("return"))
       Response.Write(Session("return"))
       Response.End()
   End Try
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900