Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

JPG File Unsupported Media Type
Started by kiteorca Feb 27 2019 03:40 AM

12 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

Hi,I got an error when trying to download a JPG file captured using my phone camera,the error in the console states that it is an unsupported media type,however,some other jpg file can be downloaded successfully,any idea what causes this?

 

UPDATE: just tried compressing the same image that failed to download using adobe photoshop,I reduced the file size to 1mb and this time the file gets downloaded! What's going on here? Could this be an issue of too big file size or compressing jpg file using adobe causes some changes on the file itself? 

 

UPDATE 2: apparently this error is caused by the file size,I opened the image file in photoshop and change the compression size back to high quality (around 5mb) and the error occurred again! 



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 683 posts
  • Corona SDK

Having more information wouldn't hurt.

What's the actual file you are trying to work with? Can you upload it or give more specific information about it? Also, when you speak of compression, are you referring to some specific compression algorithm or are you reducing the file resolution, etc.

Android devices have a hard limit regarding how large images they can handle. You can check your device's limit by using:

system.getInfo( "maxTextureSize" )

You can also check out these guidelines: https://docs.coronalabs.com/api/library/display/newImage.html#image-guidelines



[TOPIC: post.html]
#3

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

Im using a jpg file captured from my phone camera, here is ny situation:

Im buulding an app for android to let user upload inages from their phone gallery, all done using coronium core, and this all works perfectly, not problem at all here.

I also build a windows application with corona to download the inages that the user uploaded to the server, here is where the problem arise

Small jpg file around 1mb can be downloaded successfully, both in the simulator (the file downloaded to the sandbox folder) and on the windows build itself (located in appdata folder)

What I mean by compression is actually saving the jpg file (overwriting the same jpg file) but choosing the lower quality option

[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 683 posts
  • Corona SDK

Ah, so it was just about the downloading procedure? I misunderstood you then. Based on the title "JPG File Unsupported Media Type", I thought that you had problems with creating an image.

 

Well, if the download process works for smaller images, I have no idea why it might fail for larger ones. From what I remember, Coronium has good event listeners, so just check its documentation and you'll be able to print out the event results to see where it fails.
 

You didn't mention if you try to do something with the image afterwards, so if you are and if you don't receive any errors and the download itself succeeds, then have you made sure that you actually wait for the download to finish before trying to do something with the image?



[TOPIC: post.html]
#5

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

Immediately after I pressed the download button, the unsupported media type error shows up in the console

I will try to see the error handler again and see what else can be found there

I run a photo printing business and trying to build this app to have customer upload their images from their phone without the need to come to my shop, really hope someone here could help me with this issue as this could make or break the app that I'm building

[TOPIC: post.html]
#6

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

This might be not related, but the download progress prints a negative value (something like -0.59) when in coronium docs it is stated that this progress value should be between 0 and 1

[TOPIC: post.html]
#7

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

Hi, could someone help me try to upload and download this file using the core upload and download function to check if it works? Im using digitalocean server, the upload function works fine, the download returns an unsupported media type error in the console.

Here is the link to the file, (a random wallpaper I found)
https://www.pexels.com/photo/daylight-forest-glossy-lake-443446

[TOPIC: post.html]
#8

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

Some additional information,I printed the error code using the print(evt.error) function and it returns error code 415 in the console

Ichecked google and found out about this error code:

 

The HTTP 415 Unsupported Media Type client error response code indicates that the server refuses to accept the request because the payload format is in an unsupported format.

The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly.



[TOPIC: post.html]
#9

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 950 posts
  • Corona SDK

I have had issues with JPGs captured on Android phones before when opening them with Photoshop. The Galaxy A3 was especially troublesome. I never figured out why, but I can tell you some phones probably write less-than-perfect JPGs.



[TOPIC: post.html]
#10

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

I wonder if the Amazon S3 lite pkugin for coronium could solve this problem... Might wait for develephant to chime in here.

[TOPIC: post.html]
#11

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

So I tried the S3 lite demo from develephant,and the file that didnt download using the coronium core download function now downloaded perfectly!

 

But now there is an error right after the fille got downloaded:

 

01:58:55.624  ERROR: Runtime error
01:58:55.624  bad argument #1 to 'find' (string expected, got table)
01:58:55.624  stack traceback:
01:58:55.624  [C]: in function 'find'
01:58:55.624  ?: in function 'ParseXmlText'
01:58:55.624  ?: in function 'get_error_msg'
01:58:55.624  ?: in function <?:384>
 
Id like to purchase this plugin,but this error is causing another roadblock for me,really cant catch a break here...


[TOPIC: post.html]
#12

Develephant

[GLOBAL: userInfoPane.html]
Develephant
  • Corona Geek

  • 1,450 posts
  • Corona SDK

Hi, What version of Coronium are you running? Does the file extension end in .jpg or .jpeg. (your example link is jpeg) have you tried other files with any success. Generally this has to do with compression issues, such as an embedded color profile from PS. But it could also be a hard limit in download size, which I think is adjustable in Coronium. The issue seems to ring a bell. S3 and Coronium are completely different backends. The XML issue is new and something to do with S3 change in XML being returned. Looking into it. -dev
  • kiteorca likes this

[TOPIC: post.html]
#13

kiteorca

[GLOBAL: userInfoPane.html]
kiteorca
  • Observer

  • 24 posts
  • Corona SDK

Hi,What version of Coronium are you running?Does the file extension end in .jpg or .jpeg. (your example link is jpeg) have you tried other files with any success.Generally this has to do with compression issues, such as an embedded color profile from PS. But it could also be a hard limit in download size, which I think is adjustable in Coronium. The issue seems to ring a bell.S3 and Coronium are completely different backends. The XML issue is new and something to do with S3 change in XML being returned. Looking into it.-dev


Hi dev, glad that you re replying, :) hope you re getting better!

Im using coronium 2.6.5 currently, I managed to solve the download issue by using your amazon s3 plugin, for the xml issue I create my own error handler function with the unhandlederror listener to handle the error and stop the app from crashing, so far it works but would be glad if you could update the plugin to fix the error :)


[topic_controls]
[/topic_controls]