AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 02.03.2016, 02:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
goshoom: File upload and download in AX 7
Источник: http://dev.goshoom.net/en/2016/03/fi...nload-in-ax-7/
==============

New Dynamics AX is a web application running in cloud, so how can users work with files in such an environment? The answer is: in the same way as with other web applications. If you know how to add and download attachments in your webmail client, you can do it in AX 7 as well.

And it’s not too difficult for developers either.

Let me demonstrate it on a simple form I’ve built.



When you click the Upload button, a dialog opens where you can pick a file on your computer and upload it. It even shows progress of uploading.



The whole upload is triggered by a single statement: File::GetFileFromUser(). You don’t have to deal with any details.

By default, the file is uploaded to a temporary blob storage and can be accessed through some ugly URL such as this:



If you click the download button, it will navigate to the URL and your browser will do the rest:



Code of Download button is again a one-liner: new Browser().navigate(fileUrl).

This is the complete code of the form, showing also how to get the URL of the uploaded file:

[Form] public class UploadDownloadForm extends FormRun { str fileUrl; [Control("Button")] class UploadButton { public void clicked() { FileUploadTemporaryStorageResult result = File::GetFileFromUser() as FileUploadTemporaryStorageResult; if (result && result.getUploadStatus()) { fileUrl = result.getDownloadUrl(); info(fileUrl); } } } [Control("Button")] class DownloadButton { public void clicked() { new Browser().navigate(fileUrl); } } }






Your files typically aren’t accessible by URL, because they’re in database or in a secured storage. But that’s not a problem. Just load the content of your file to a stream and pass it to File::SendFileToUser(). It will put the file to the temporary blob storage and navigate to the URL, therefore users can download the file in the same way as above.



Источник: http://dev.goshoom.net/en/2016/03/fi...nload-in-ax-7/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
patrickmouwen: Dynamics AX Retail 3rd party POS and E-commerce integration – Solution Design Blog bot DAX Blogs 0 26.10.2015 12:11
patrickmouwen: Dynamics AX Retail 3rd party POS and E-commerce integration – Control dashboard Blog bot DAX Blogs 0 26.10.2015 12:11
emeadaxsupport: Connecting Retail Components on an External Computer to the Microsoft Dynamics AX R3 Azure Lifecycle Services Demo Virtual Machine Blog bot DAX Blogs 0 28.06.2014 00:13
msdyncomm: How Do I: Use the Silent File Upload and Download Pattern in Microsoft Dynamics NAV 2013 R2 Blog bot NAV: Blogs 0 24.03.2014 22:12
emeadaxsupport: New Content for Microsoft Dynamics AX 2012 : October 2011 Blog bot DAX Blogs 0 27.10.2011 17:11

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 10:33.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.