AL icon indicating copy to clipboard operation
AL copied to clipboard

Implement MediaSet.ExportStream

Open bvbeek opened this issue 8 years ago • 16 comments

If we use the code from standard NAV page Item Picture, we get several errors (see printscreen)

I think we need something like this:

Picture.EXPORTTOSTREAM(InStream)
DOWNLOADFROMSTREAM

image

bvbeek avatar Sep 18 '17 08:09 bvbeek

Item Picture as part of the base application is allowed to use files, but these are not allowed in Extensions. Like you mentioned you should use ExportToStream and DownloadFromStream

StanislawStempin avatar Sep 18 '17 09:09 StanislawStempin

ExportToStream is not available

bvbeek avatar Sep 18 '17 09:09 bvbeek

Ok, I understand now - we will look into adding MediaSet.ExportStream function.

StanislawStempin avatar Oct 05 '17 08:10 StanislawStempin

Thank you!

bvbeek avatar Oct 05 '17 08:10 bvbeek

ExportStream function seemed to be available. It creates an Outstream. The DOWNLOADFROMSTREAM functions needs an InStream and the COPYSTREAM function only copies an InStream to an Outsstream, right?

Example: Cover.ExportStream(NVOutStream); // TODO: How to convert to InStream? DOWNLOADFROMSTREAM(NVInStream,'Export','','All Files (.)|.',ToFile);

jiwanovski87 avatar Oct 23 '17 15:10 jiwanovski87

Indeed ;)

bvbeek avatar Oct 24 '17 08:10 bvbeek

ExportStream function seemed NOT available for Mediaset. How can I export picture from Mediaset ? default

YashinaElena avatar Feb 22 '18 13:02 YashinaElena

You can use the new stream functions to do this. See here: https://navbitsbytes.wordpress.com/2017/12/08/al-extensions-importing-and-exporting-media-sets/

MikeGlue avatar Feb 22 '18 19:02 MikeGlue

ExportStream on the MediaSet is not available yet but please try following the process that Mike outlined above.

StanislawStempin avatar Feb 23 '18 08:02 StanislawStempin

Thanks very much ! Really helped.

2018-02-23 11:42 GMT+03:00 Stanislaw Stempin [email protected]:

ExportStream on the MediaSet is not available yet but please try following the process that Mike outlined above.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/AL/issues/692#issuecomment-367945593, or mute the thread https://github.com/notifications/unsubscribe-auth/AiSvpaDEGkLbEIQaZs0mDJtz7qon9Eqnks5tXnn2gaJpZM4Pajkg .

YashinaElena avatar Feb 26 '18 06:02 YashinaElena

Is there any update on this issue? In 16.0 there is still no option to export a MediaSet. The Picture.ExportFile is still not available for extension development and yet in the base application still used by the Item Picture page. We have many other tables with a media set and want to be able to use standard functions to export (to local device).

RobertdeRoos avatar Apr 28 '20 13:04 RobertdeRoos

Hi @RobertdeRoos ! Did the solution proposed by Mike not work?

atoader avatar May 05 '20 19:05 atoader

Hi @RobertdeRoos ! Did the solution proposed by Mike not work?

The link is not working anymore, so I do not know what the solution proposed by Mike is... image

RobertdeRoos avatar May 07 '20 06:05 RobertdeRoos

Sorry, I moved my blog since then.....here is the new link: https://navbitsbytes.com/2017/12/08/al-extensions-importing-and-exporting-media-sets/

MikeGlue avatar May 07 '20 16:05 MikeGlue

@MikeGlue could you please update your URL or remove it, since it leads to an spam website?

Are there any plans to implement this feature request on the platform?

My Workaround do deal with the current situation

for MediaObjectIndex := 1 to Rec."Picture".Count() do begin
    if TenantMedia.Get(Rec."Picture".Item(MediaObjectIndex)) then begin
        TenantMedia.CalcFields(Content);
        if TenantMedia.Content.HasValue() then begin
            TenantMedia.Content.CreateInStream(PictureInStream);
            DownloadFromStream(PictureInStream, '', '', '', ToFile);
        end;
    end;
end;

pri-kise avatar Dec 07 '22 06:12 pri-kise

The mistake a lot of developers make is to first use calcfields on a blob before using HasValue. If a Blob field contains data the HasValue will return true without the use of calcfields. So correct code from pri-kise would be:

for MediaObjectIndex := 1 to Rec."Picture".Count() do begin
    if TenantMedia.Get(Rec."Picture".Item(MediaObjectIndex)) then begin
        if TenantMedia.Content.HasValue() then begin
            TenantMedia.CalcFields(Content);
            TenantMedia.Content.CreateInStream(PictureInStream);
            DownloadFromStream(PictureInStream, '', '', '', ToFile);
        end;
    end;
end;

RobertatK3 avatar Dec 07 '22 07:12 RobertatK3