{ "id": "133849", "key": "TIMOB-17626", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "16723", "description": "Windows Platform Support, ListView updates, Vector overlays in maps", "name": "Release 4.1.0", "archived": false, "released": true, "releaseDate": "2015-07-08" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-05-21T02:12:38.000+0000", "created": "2014-07-29T13:09:33.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "TCSupport" ], "versions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2015-06-09T21:51:29.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h4. Problem Description\r\nOn Android, *Ti.Media.saveToPhotoGallery()* saves a file or a blob without any file extension, which makes it impossible for the photo gallery to recognize the file.\r\n\r\nThe issue can be reproduced with the following code, with the picture test.jpg being stored in project/app/assets. Note that in this example, I use *Ti.Media.saveToPhotoGallery* with a blob but I get exactly the same result with a file.\r\n\r\n{code:javascript}\r\n\r\nvar file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, \"/test.jpg\");\r\nTi.Media.saveToPhotoGallery(file.read(), {\r\n\tsuccess: function() {\r\n\t\talert('success');\r\n\t},\r\n\terror: function() {\r\n\t\talert('error');\r\n\t}\r\n});\r\n{code}\r\n\r\nI receive a success, but the image is saved without extension and I get this message in the console:\r\n\r\nD/MediaScannerReceiver(25405): action: android.intent.action.MEDIA_SCANNER_SCAN_FILE path: /storage/emulated/0/Pictures/TestApp/tia636479782jpeg\r\n\r\nh4. Steps to Reproduce:\r\n1. Create a Classic project.\r\n2. Paste this code in app.js file.\r\n3. Paste a photo to the resources folder named test.jpg.\r\n4. Run this code with the testing environment.\r\n\r\nh3.Test Code:\r\n{code:title=app.js}\r\nvar win = Titanium.UI.createWindow({\r\n\tbackgroundColor : \"#000\",\r\n});\r\n\r\nvar photo = Ti.UI.createButton({\r\n\ttitle : 'Save Photo',\r\n\theight : Ti.UI.SIZE,\r\n\twidth : Ti.UI.SIZE,\r\n\ttop : 20,\r\n\tcolor : \"#fff\"\r\n\r\n});\r\n\r\nwin.add(photo);\r\n\r\n// Listen for click events.\r\nphoto.addEventListener('click', function() {\r\n\tfile = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, \"test.jpg\");\r\n\talert(file.nativePath);\r\n\tTi.Media.saveToPhotoGallery(file.read(), {\r\n\t\tsuccess : function() {\r\n\t\t\talert('success');\r\n\t\t},\r\n\t\terror : function() {\r\n\t\t\talert('error');\r\n\t\t}\r\n\t});\r\n\r\n});\r\n\r\nwin.open();\r\n\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Ti.Media.saveToPhotoGallery() saves pictures without file extension on Android", "creator": { "name": "FrancoisM", "key": "francoism", "displayName": "François Mériaux", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "FrancoisM", "key": "francoism", "displayName": "François Mériaux", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK 3.3.0 G.A., Alloy 1.4.0, Android 4.4.4, Nexus 5\r\nTitanium SDK: 3.3.0.GA,\r\nTitanium CLI: 3.3.0,\r\nAndroid SDK: 4.4.3, 4.2.2,\r\nOS X Version: 10.9.4,\r\nAppcelerator Studio: 3.3.0\r\n", "closedSprints": [ { "id": 407, "state": "closed", "name": "2015 Sprint 11 SDK", "startDate": "2015-05-23T00:00:08.253Z", "endDate": "2015-06-06T00:00:00.000Z", "completeDate": "2015-06-08T16:18:16.381Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "316620", "author": { "name": "FrancoisM", "key": "francoism", "displayName": "François Mériaux", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Can anyone reproduce this issue?", "updateAuthor": { "name": "FrancoisM", "key": "francoism", "displayName": "François Mériaux", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-01T09:03:08.000+0000", "updated": "2014-08-01T09:03:08.000+0000" }, { "id": "322049", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "confirmed on a Nexus 4 (4.4.4), SDK 3.3.0\r\n\r\n09-05 18:05:50.721: D/MediaScannerReceiver(32662): action: android.intent.action.MEDIA_SCANNER_SCAN_FILE path: /storage/emulated/0/Pictures/testapp/tia333724776png\r\n\r\nWhen I look inside the folder the file is really saved without the dot (tia333724776png)", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-09-05T16:08:43.000+0000", "updated": "2014-09-05T16:08:43.000+0000" }, { "id": "324681", "author": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue reproduces\r\n\r\nTitanium SDK version 3.4.0 master, 3.3.0.GA\r\nTitanium Studio, build: 3.3.0.201407100905\r\nTitanium Command-Line Interface\r\nCLI version 3.3.0, \r\nAndroid device : Motorola Moto G, Android version : 4.4.4", "updateAuthor": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-19T09:08:08.000+0000", "updated": "2014-09-19T09:08:08.000+0000" }, { "id": "339877", "author": { "name": "levieraf", "key": "levieraf", "displayName": "LUIS VIERA", "active": true, "timeZone": "America/Bogota" }, "body": "Issue reproduces\r\n\r\nTitanium SDK version 3.4.0.\r\nAndroid device: Nexus 5, Android version: 5.0.1\r\n\r\n\r\nThis issue happening when I use:\r\n.\r\n.\r\nCASE 1: \r\nphoto.addEventListener('click', function() {\r\n\tfile = Ti.Filesystem.getFile(Titanium.Filesystem.tempDirectory, \"test.jpg\");\r\n\talert(file.nativePath);\r\n\tTi.Media.saveToPhotoGallery(file.read(), {\r\n.\r\n.\r\n.\r\n\r\nHowever, if I put a image on assets/android/images/, then, I make for example\r\n\r\n.\r\n.\r\nCASE 2:\r\n\tvar imagen_prueba = Ti.UI.createImageView({\r\n\t\timage : '/images/bandera.jpg',\r\n\t\twidth : \"300dp\",\r\n\t\theight : \"300dp\"\r\n\t});\r\n\r\n Ti.Media.saveToPhotoGallery(imagen_prueba.toBlob(), {\r\n.\r\n.\r\n.\r\n\r\n\r\nUsing this way, work perfect!.\r\n\r\n", "updateAuthor": { "name": "levieraf", "key": "levieraf", "displayName": "LUIS VIERA", "active": true, "timeZone": "America/Bogota" }, "created": "2015-01-20T12:44:23.000+0000", "updated": "2015-01-20T12:44:50.000+0000" }, { "id": "340084", "author": { "name": "levieraf", "key": "levieraf", "displayName": "LUIS VIERA", "active": true, "timeZone": "America/Bogota" }, "body": "I solved the issue the following way:\r\n\r\nvar imagen_prueba = Ti.UI.createImageView({\r\n\timage : \"/images/bandera.jpg\",\r\n\twidth : \"50dp\",\r\n\theight : \"50dp\",\r\n\ttop : \"0dp\",\r\n\tzIndex : 2,\r\n\tleft : \"0dp\"\r\n});\r\n\r\nvar imagen_view = Ti.UI.createView({\r\n\twidth : \"300dp\",\r\n\theight : \"300dp\",\r\n\tbackgroundColor : \"RED\",\r\n\tzIndex : 1\r\n});\r\n\r\nimagen_view.add(imagen_prueba);\r\n$.contenedor.add(imagen_view);\r\n\r\n$.accion.addEventListener('click', function() {\r\n\r\n\tvar blob = imagen_view.toImage();\r\n\r\n\tvar file = Titanium.Filesystem.getFile(Titanium.Filesystem.tempDirectory, \"imagen.jpg\");\r\n\r\n\tif (file.write(blob.media)) {\r\n\r\n\t\tvar image_tmp = Ti.UI.createImageView({\r\n\t\t\timage: file.nativePath,\r\n\t\t\theight: \"300dp\",\r\n\t\t\twidth: \"300dp\"\r\n\t\t});\r\n\r\n\t\tTi.Media.saveToPhotoGallery(image_tmp.toBlob(), {\r\n\t\t\tsuccess : function(e) {\r\n\t\t\t\tTi.API.info(\"listo, revisa!\");\r\n\t\t\t},\r\n\t\t\terror : function() {\r\n\t\t\t\tTi.API.info(\"Ocurrio un error!\");\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t} else {\r\n\t\talert(\"No se guardo la imagen\");\r\n\t\tTi.API.info(\"No se guardo la imagen\");\r\n\t}\r\n\r\n});\r\n\r\n$.index.open();\r\n\r\n\r\n.\r\n.\r\n.\r\n\r\nAfter to save the image I create a object image and then I make image_tmp.toBlob(), with this, the result is something like that:\r\n\r\n.....tia333724776.png :) !!!!\r\n\r\n\r\nThanks, I wanted to shared with you.\r\n\r\nGood luck!", "updateAuthor": { "name": "levieraf", "key": "levieraf", "displayName": "LUIS VIERA", "active": true, "timeZone": "America/Bogota" }, "created": "2015-01-21T03:56:52.000+0000", "updated": "2015-01-21T03:56:52.000+0000" }, { "id": "340523", "author": { "name": "tokmakoff", "key": "tokmakoff", "displayName": "Andrew Tokmakoff", "active": true, "timeZone": "Australia/Adelaide" }, "body": "MediaModule uses TiMimeTypeHelper to get the mimetype of the image. This in turn uses android.webkit.MimeTypeMap which returns the extension minus the preceding \".\".\r\n\r\nhttp://developer.android.com/reference/android/webkit/MimeTypeMap.html\r\n\r\nSo, the fix is to adjust the call to TiMimeTypeHelper such that the returned value has the \".\" prefixed.\r\n\r\nline 372 \r\nchanges from\r\n\t\t\t\t\textension = TiMimeTypeHelper.getFileExtensionFromMimeType(mimetype, \".jpg\");\r\n\r\nto become:\r\n\r\n\t\t\t\t\textension = \".\" + TiMimeTypeHelper.getFileExtensionFromMimeType(mimetype, \"jpg\");\r\n\r\nThis works for me.\r\n\r\n", "updateAuthor": { "name": "tokmakoff", "key": "tokmakoff", "displayName": "Andrew Tokmakoff", "active": true, "timeZone": "Australia/Adelaide" }, "created": "2015-01-25T05:45:48.000+0000", "updated": "2015-01-25T05:46:34.000+0000" }, { "id": "353059", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/6862", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-05-20T08:11:33.000+0000", "updated": "2015-05-20T08:11:33.000+0000" }, { "id": "353164", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR reviewed and functionally tested. Merged.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-05-21T02:13:26.000+0000", "updated": "2015-05-21T02:13:26.000+0000" }, { "id": "354703", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\nThe picture is saved with an extension.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.1.0.201505071004\r\nTi SDK : 4.1.0.v20150605164428\r\nTi CLI : 4.0.1\r\nAlloy : 1.6.0\r\nMAC Yosemite : 10.10.3\r\nAppc npm : 4.0.0\r\nAppc CLI : 4.0.2-rc2\r\nNode: v0.10.37\r\nDevice - Android 5.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-06-09T21:51:14.000+0000", "updated": "2015-06-09T21:51:14.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }