You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2020/05/19 09:09:16 UTC

[GitHub] [royale-asjs] nihavend opened a new issue #838: mx.net.FileReference save method is not implemented

nihavend opened a new issue #838:
URL: https://github.com/apache/royale-asjs/issues/838


   Test Case 
   
   ```
   <?xml version="1.0" encoding="utf-8"?>
   <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   			   xmlns:s="library://ns.apache.org/royale/spark"
   			   xmlns:mx="library://ns.apache.org/royale/mx"
   			   paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0"
   			   height="100%" width="100%" 
   			   >
   	
   	<fx:Script>
   		<![CDATA[
   			
   			import mx.net.FileReference;
   			import mx.events.MenuEvent;
   			
   			
   			protected function saveXML(event:MouseEvent):void {
   				var fileReference:FileReference = new FileReference();
   				fileReference.save(menuDataXMLList.toString(), "pinaraexport.xml");
   			}
   			
   		]]>
   	</fx:Script>
   	
   	<fx:Declarations>
   		<fx:XMLList id="menuDataXMLList">
   			<menuitem label="label-1">			
   				<menuitem label="label-1-1"/>			
   				<menuitem label="label-1-2"/>			
   			</menuitem>
   			<menuitem label="Switch Locale" id="admin" >			
   				<menuitem label="label-2-1"/>			
   				<menuitem label="label-2-2"/>			
   				<menuitem label="label-2-3" id="admin" />
   			</menuitem>
   		</fx:XMLList>
   	</fx:Declarations>	
   	
   	<s:layout>
   		<s:VerticalLayout gap="10" paddingRight="10" paddingLeft="10" paddingTop="10" paddingBottom="20" />
   	</s:layout>
   
   	<s:Button label="Save XML" click="saveXML(event)" visible="true" includeInLayout="true"/>
   	
   </s:Application>
   
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] nihavend commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
nihavend commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-634503487


   In theory I do not want to restrict my app with specific browser as Royale does not I guess.
   
   For the reality it is not a requirement to select a folder for the file to save but it is nice to have feature.
   
   I can switch to Anchor for pass this issue.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] nihavend commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
nihavend commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-636300765


   Download works, confirm.
   @aharui need some fine tuning related with size (esp. width) of the component according to the length of the label.It may be a big issue with lcalization.
   
   ![image](https://user-images.githubusercontent.com/5983818/83324073-4faa9080-a26b-11ea-8a3a-a5ccfc82a062.png)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] aharui commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
aharui commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633312491


   Yes, that's true, but AFAICT, there is no opportunity for the user to pick the destination folder/filename.  The file ends up in their "downloads" folder.  A full emulation pops up a file finding dialog.  But putting an Anchor tag with an href as a link in the DOM allows the user to right-click and choose a destination folder/filename, at least on Chrome OS X.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] asifashfaq commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
asifashfaq commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-736557480


   its only working for string type data.
   
   i have tested it. when i have assigned it data in BytesArray. it gives me wrong or corupted pdf file or jpg or excel file.
   
   i have opened a new issue #971 with complete examples.
   live test also available on vdi.
   Give response on it.
   Thanks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] bigosmallm edited a comment on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
bigosmallm edited a comment on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633303391


   I believe you can initiate a download without the need for an explicit click action from the user.  This seems to work:
   
   ```var saveData = (function () {
       var a = document.createElement("a");
       document.body.appendChild(a);
       a.style = "display: none";
       return function (data, fileName) {
           var json = JSON.stringify(data),
               blob = new Blob([json], {type: "octet/stream"}),
               url = window.URL.createObjectURL(blob);
           a.href = url;
           a.download = fileName;
           a.click();
           window.URL.revokeObjectURL(url);
       };
   }());
   
   var data = { x: 42, s: "hello, world", d: new Date() },
       fileName = "my-download.json";
   
   saveData(data, fileName);
   ```
   
   Source: https://jsfiddle.net/koldev/cW7W5/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] aharui commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
aharui commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633152155


   AFAICT, there is no practical way to do an emulation of FileReference.save.  The best replacement I've found so far is to set the href on an Anchor element to a Blob.  If the user clicks on it, it will download to the user's Downloads folder.  If they right-click, some browsers will let them choose where to download it.
   
   If that is acceptable, we can create a component that will do that.  The key workflow difference is that the data will have to be ready before the button is clicked.  So the "Save XML" button might popup another dialog that contains the Anchor element.
   
   Or maybe someone else knows how to emulate FileReference.save


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] Harbs commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
Harbs commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633460068


   That's pretty cool. I didn't know about the native file system APIs. It looks like it's only available so far in Chrome and only when enabling a flag: https://caniuse.com/#feat=native-filesystem-api
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] aharui closed issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
aharui closed issue #838:
URL: https://github.com/apache/royale-asjs/issues/838


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] bigosmallm commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
bigosmallm commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633303391


   I believe you can initiate a download without the need for an explicit click action from the user.  This seems to work:
   
   `var saveData = (function () {
       var a = document.createElement("a");
       document.body.appendChild(a);
       a.style = "display: none";
       return function (data, fileName) {
           var json = JSON.stringify(data),
               blob = new Blob([json], {type: "octet/stream"}),
               url = window.URL.createObjectURL(blob);
           a.href = url;
           a.download = fileName;
           a.click();
           window.URL.revokeObjectURL(url);
       };
   }());
   
   var data = { x: 42, s: "hello, world", d: new Date() },
       fileName = "my-download.json";
   
   saveData(data, fileName);
   `
   
   Source: https://jsfiddle.net/koldev/cW7W5/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] nihavend commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
nihavend commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-634487610


   Flex version also uses native browser's browse window prior saving the data.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] aharui commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
aharui commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-635823196


   Here's the app using DownloadButton that I just pushed:
   
   ```
   <?xml version="1.0" encoding="utf-8"?>
   <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   			   xmlns:s="library://ns.apache.org/royale/spark"
   			   xmlns:mx="library://ns.apache.org/royale/mx"
   			   paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0"
   			   height="100%" width="100%" 
   			   creationComplete="setupDownload()">
   	
   	<fx:Script>
   		<![CDATA[
   			
   			import mx.net.FileReference;
   			import mx.events.MenuEvent;
   			
   			
   			protected function setupDownload():void {
   				downloadButton.defaultFileName = "pinaraexport.xml";
   				downloadButton.data = menuDataXMLList.toString()
   				//var fileReference:FileReference = new FileReference();
   				//fileReference.save(menuDataXMLList.toString(), "pinaraexport.xml");
   			}
   			
   		]]>
   	</fx:Script>
   	
   	<fx:Declarations>
   		<fx:XMLList id="menuDataXMLList">
   			<menuitem label="label-1">			
   				<menuitem label="label-1-1"/>			
   				<menuitem label="label-1-2"/>			
   			</menuitem>
   			<menuitem label="Switch Locale" id="admin" >			
   				<menuitem label="label-2-1"/>			
   				<menuitem label="label-2-2"/>			
   				<menuitem label="label-2-3" id="admin" />
   			</menuitem>
   		</fx:XMLList>
   	</fx:Declarations>	
   	
   	<s:layout>
   		<s:VerticalLayout gap="10" paddingRight="10" paddingLeft="10" paddingTop="10" paddingBottom="20" />
   	</s:layout>
   
   	<mx:DownloadButton label="Save XML" id="downloadButton"/>
   	
   </s:Application>
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] aharui commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
aharui commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-634495632


   @nihavend is your app only using Chrome?  Does your app require that the user choose a directory or can it download to a predetermined folder? Can you switch to using an Anchor element with the data ready before click?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] greg-dove commented on issue #838: mx.net.FileReference save method is not implemented

Posted by GitBox <gi...@apache.org>.
greg-dove commented on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633378555


   That's what I understand also. I didn't try the right-click approach, I simply used the downloads approach (with a user action) on the graphics demo I did a few months back, for saving the generated svgs.
   
   But the native file system api is coming and it works (for me) in Chrome already, there's a 'try it' link in this page:
   https://web.dev/native-file-system/
   
   This is the type of thing that I think might be nice to consider implementing as forward-compatible., or at least supporting it as an option early. We could expect that Edge and Opera and Chrome should have it pretty soon at least. I think we can be reasonably sure that IE11 will never have it.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org