Send image to asp.net web service from IOS

前端 未结 1 622
春和景丽
春和景丽 2021-01-06 13:20

In my IOS app i need o send a image to ASP.NET Web Service . I am trying to the image in bytes form & then convert it back to image form on server side. Now i am using

相关标签:
1条回答
  • 2021-01-06 13:48
    • You can reduce the memory footage of the image using JPEG image compression

      lowResolutionImage = [UIImage imageWithData:UIImageJPEGRepresentation(highResImage, quality)];
      

      where quality is between 0.0 and 1.0

    • Don't send the image as raw binary over the internet turn the binary into base64 string

    because some media are made for streaming text. You never know some protocols may interpret your binary data as control characters , or your binary data could be screwed up because the underlying protocol might think that you've entered a special character combination.

    Here is the link on how to convert into base64

    • As you are using IIS for hosting your application, then the default upload file size if 4MB. To increase it, please use this below section in your web.config

      <configuration>
          <system.web>
              <httpRuntime maxRequestLength="1048576" />
          </system.web>
      </configuration>
      

      For IIS7 and above, you also need to add the lines below:

      <system.webServer>
         <security>
            <requestFiltering>
             <requestLimits maxAllowedContentLength="1073741824" />
            </requestFiltering>
        </security>
      

    Note: maxAllowedContentLength is measured in bytes while maxRequestLength is measured in kilobytes, which is why the values differ in this config example. (Both are equivalent to 1 GB.)

    Here is an answer for another question that'd be helpful to you

    0 讨论(0)
提交回复
热议问题