logo
down
shadow

Uploading image with IOS app to server file size is too large


Uploading image with IOS app to server file size is too large

By : user2953984
Date : November 21 2020, 07:31 AM
may help you . The problem is UIImageJPEGRepresentation. It does not retrieve the original JPEG, but rather creates a new JPEG. And when you use a compressionQuality of 1 (presumably to avoid further image quality loss), it creates this new representation with no compression (generally resulting in a file larger than the original).
I would advise using getBytes to retrieve the original asset, rather than round-tripping it through a UIImage and getting the data via UIImageJPEGRepresentation:
code :
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetsLibraryURL resultBlock:^(ALAsset *asset) {
    ALAssetRepresentation *representation = [asset defaultRepresentation];

    // I generally would write directly to a `NSOutputStream`, but if you want it in a
    // NSData, it would be something like:

    NSMutableData *data = [NSMutableData data];

    // now loop, reading data into buffer and writing that to our data stream

    NSError *error;
    long long bufferOffset = 0ll;
    NSInteger bufferSize = 10000;
    long long bytesRemaining = [representation size];
    uint8_t buffer[bufferSize];
    while (bytesRemaining > 0) {
        NSUInteger bytesRead = [representation getBytes:buffer fromOffset:bufferOffset length:bufferSize error:&error];
        if (bytesRead == 0) {
            NSLog(@"error reading asset representation: %@", error);
            return;
        }
        bytesRemaining -= bytesRead;
        bufferOffset   += bytesRead;
        [data appendBytes:buffer length:bytesRead];
    }

    // ok, successfully read original asset; 
    // do whatever you want with it here

} failureBlock:^(NSError *error) {
    NSLog(@"error=%@", error);
}];
PHFetchResult *result = [PHAsset fetchAssetsWithALAssetURLs:@[assetsLibraryURL] options:nil];
PHAsset *asset = [result firstObject];
if (asset) {
    PHImageManager *manager = [PHImageManager defaultManager];
    [manager requestImageDataForAsset:asset options:nil resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
        // use `imageData` here
    }];
}


Share : facebook icon twitter icon
Uploading multiple images to server. If only one image is bigger than size limit or wrong file extension then all other

Uploading multiple images to server. If only one image is bigger than size limit or wrong file extension then all other


By : Ronak Jain
Date : March 29 2020, 07:55 AM
To fix this issue Work only on the specific item/file within your loop.
So, this: string FileExtension = System.IO.Path.GetExtension(UploadImages.FileName); Should be: string FileExtension = System.IO.Path.GetExtension(uploadedFile.FileName);
Laravel PHP: Uploading Image with Large file size results in 'getClientOriginalName()' being 'null'

Laravel PHP: Uploading Image with Large file size results in 'getClientOriginalName()' being 'null'


By : Apoorva
Date : March 29 2020, 07:55 AM
it should still fix some issue Since your controller action is store I'm guessing you have a restfull controller and for that action the HTTP method is POST. If that's the case you need to make sure you set also set the post_max_size in your php.ini:
code :
post_max_size = 25M
413 Request Entity Too Large in wcf service when uploading large image file

413 Request Entity Too Large in wcf service when uploading large image file


By : Karin Janssen
Date : March 29 2020, 07:55 AM
this one helps. While you have defined a basicHttpBinding with larger than default values, you have not told the WCF service to actually use that binding. When no service endpoints are defined, the default out of the box binding is basicHttpBinding with the default values.
You can either set your defined binding as the default binding configuration for any services using basicHttpBinding that use that config file by omitting the name attribute in the binding definition, like this:
code :
<bindings>
  <basicHttpBinding>
    <binding maxBufferPoolSize="2147483647" 
             maxReceivedMessageSize="2147483647" 
             maxBufferSize="2147483647">
      <readerQuotas maxDepth="200" 
                    maxStringContentLength="8388608" 
                    maxArrayLength="16384" 
                    maxBytesPerRead="2147483647" 
                    maxNameTableCharCount="16384" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="MyService">
    <endpoint address="" binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IService"
              contract="MyNamespace.IServiceContract" />
    </endpoint>
  </service>
<configuration>
  <system.web>
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>
</configuration>
<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding maxBufferPoolSize="2147483647" 
               maxReceivedMessageSize="2147483647" 
               maxBufferSize="2147483647">
        <readerQuotas maxDepth="200" 
                      maxStringContentLength="8388608" 
                      maxArrayLength="16384" 
                      maxBytesPerRead="2147483647" 
                      maxNameTableCharCount="16384" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
  </protocolMapping>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
                             multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IService"
               maxBufferPoolSize="2147483647" 
               maxReceivedMessageSize="2147483647" 
               maxBufferSize="2147483647">
        <readerQuotas maxDepth="200" 
                      maxStringContentLength="8388608" 
                      maxArrayLength="16384" 
                      maxBytesPerRead="2147483647" 
                      maxNameTableCharCount="16384" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <services>
    <service name="MyService">
      <endpoint address="" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService"
                contract="MyNamespace.IServiceContract" />
      </endpoint>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
  </protocolMapping>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
                             multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Large size image is not uploading in server using PHP

Large size image is not uploading in server using PHP


By : peregrinogris
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Steps:
Check if PHP returns any error Define your own max size for this app. Get actual maximum upload size (based in your own max size and server settings). Check if the file size exceeds the limit
code :
function convertToBytes( $value ) {
  if ( is_numeric($value) ) {
    return $value;
  } else {
    $value_length = strlen(trim($value));
    $bytes = substr($value, 0, $value_length - 1);
    $unit = strtolower(substr($value, $value_length - 1));
    switch( $unit ) {
      case 'g':
        $bytes *= 1024;
      case 'm':
        $bytes *= 1024;
      case 'k':
        $bytes *= 1024;
    }
    return $bytes;            
  }
}

function getFileUploadMaxSize($app_config_max_size) {
  return min(min(convertToBytes(ini_get('post_max_size')), convertToBytes(ini_get('upload_max_filesize'))), $app_config_max_size); 
}


try {
    if ( $_FILES['user_image']['error'] != UPLOAD_ERR_OK ) { // (step 1)
        throw new Exception( _FILES['user_image']['error'] );
    }
  $app_config_max_size = 10485760; // 10MB (step 2)
  $max_size = getFileUploadMaxSize($app_config_max_size); // (step 3)
    if ( $_FILES['user_image']['size'] > $max_size ) { // (step 4)
        throw new Exception( 'limit exceeded' );
    }

  ... rest of your upload code ...

} catch (Exception $e) {
  echo $e->getMessage();
}
How to reduce an Image file size before uploading to a server

How to reduce an Image file size before uploading to a server


By : Shubham Sonkar
Date : March 29 2020, 07:55 AM
Any of those help I use this function to reduce the size of image before uploading it, it reduces the image size to nearly 200 KB and keep the quality relatively good, u may modify it to fulfill your purpose by changing the REQUIRED_SIZE and inSampleSize:
Related Posts Related Posts :
  • Unclear about releasing CFDictionaryRef
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org