@sasjs/core 4.4.0 → 4.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mp_streamfile.sas +35 -18
- package/package.json +1 -1
package/base/mp_streamfile.sas
CHANGED
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
@param [in] contenttype= (TEXTS) Either TEXT, ZIP, CSV, EXCEL
|
|
16
16
|
@param [in] inloc= /path/to/file.ext to be sent
|
|
17
17
|
@param [in] inref= fileref of file to be sent (if provided, overrides `inloc`)
|
|
18
|
+
@param [in] iftrue= (1=1) Provide a condition under which to execute.
|
|
18
19
|
@param [out] outname= the name of the file, as downloaded by the browser
|
|
20
|
+
@param [out] outref= (_webout) The destination where the file should be
|
|
21
|
+
streamed.
|
|
19
22
|
|
|
20
23
|
<h4> SAS Macros </h4>
|
|
21
24
|
@li mf_getplatform.sas
|
|
@@ -29,13 +32,17 @@
|
|
|
29
32
|
contenttype=TEXT
|
|
30
33
|
,inloc=
|
|
31
34
|
,inref=0
|
|
35
|
+
,iftrue=%str(1=1)
|
|
32
36
|
,outname=
|
|
37
|
+
,outref=_webout
|
|
33
38
|
)/*/STORE SOURCE*/;
|
|
34
39
|
|
|
40
|
+
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
41
|
+
|
|
35
42
|
%let contentype=%upcase(&contenttype);
|
|
43
|
+
%let outref=%upcase(&outref);
|
|
36
44
|
%local platform; %let platform=%mf_getplatform();
|
|
37
45
|
|
|
38
|
-
|
|
39
46
|
/**
|
|
40
47
|
* check engine type to avoid the below err message:
|
|
41
48
|
* > Function is only valid for filerefs using the CACHE access method.
|
|
@@ -43,7 +50,7 @@
|
|
|
43
50
|
%local streamweb;
|
|
44
51
|
%let streamweb=0;
|
|
45
52
|
data _null_;
|
|
46
|
-
set sashelp.vextfl(where=(upcase(fileref)="
|
|
53
|
+
set sashelp.vextfl(where=(upcase(fileref)="&outref"));
|
|
47
54
|
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
|
48
55
|
run;
|
|
49
56
|
|
|
@@ -55,7 +62,7 @@ run;
|
|
|
55
62
|
run;
|
|
56
63
|
%end;
|
|
57
64
|
%else %if &platform=SASVIYA %then %do;
|
|
58
|
-
filename
|
|
65
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
59
66
|
contenttype='application/csv'
|
|
60
67
|
contentdisp="attachment; filename=&outname";
|
|
61
68
|
%end;
|
|
@@ -69,14 +76,25 @@ run;
|
|
|
69
76
|
run;
|
|
70
77
|
%end;
|
|
71
78
|
%else %if &platform=SASVIYA %then %do;
|
|
72
|
-
filename
|
|
79
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
|
73
80
|
contenttype='application/vnd.ms-excel'
|
|
74
81
|
contentdisp="attachment; filename=&outname";
|
|
75
82
|
%end;
|
|
76
83
|
%end;
|
|
84
|
+
%else %if &contentype=GIF or &contentype=JPEG or &contentype=PNG %then %do;
|
|
85
|
+
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
86
|
+
data _null_;
|
|
87
|
+
rc=stpsrv_header('Content-type',"image/%lowcase(&contenttype)");
|
|
88
|
+
run;
|
|
89
|
+
%end;
|
|
90
|
+
%else %if &platform=SASVIYA %then %do;
|
|
91
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
92
|
+
contenttype="image/%lowcase(&contenttype)";
|
|
93
|
+
%end;
|
|
94
|
+
%end;
|
|
77
95
|
%else %if &contentype=HTML %then %do;
|
|
78
96
|
%if &platform=SASVIYA %then %do;
|
|
79
|
-
filename
|
|
97
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
|
80
98
|
contenttype="text/html";
|
|
81
99
|
%end;
|
|
82
100
|
%end;
|
|
@@ -88,24 +106,20 @@ run;
|
|
|
88
106
|
run;
|
|
89
107
|
%end;
|
|
90
108
|
%else %if &platform=SASVIYA %then %do;
|
|
91
|
-
filename
|
|
109
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
92
110
|
contenttype='application/text'
|
|
93
111
|
contentdisp="attachment; filename=&outname";
|
|
94
112
|
%end;
|
|
95
113
|
%end;
|
|
96
|
-
%else %do;
|
|
97
|
-
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
|
98
|
-
%return;
|
|
99
|
-
%end;
|
|
100
|
-
%else %if &contentype=WOFF %then %do;
|
|
114
|
+
%else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
|
|
101
115
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
102
116
|
data _null_;
|
|
103
|
-
rc=stpsrv_header('Content-type',
|
|
117
|
+
rc=stpsrv_header('Content-type',"font/%lowcase(&contenttype)");
|
|
104
118
|
run;
|
|
105
119
|
%end;
|
|
106
120
|
%else %if &platform=SASVIYA %then %do;
|
|
107
|
-
filename
|
|
108
|
-
contenttype=
|
|
121
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
122
|
+
contenttype="font/%lowcase(&contenttype)";
|
|
109
123
|
%end;
|
|
110
124
|
%end;
|
|
111
125
|
%else %if &contentype=XLSX %then %do;
|
|
@@ -117,7 +131,7 @@ run;
|
|
|
117
131
|
run;
|
|
118
132
|
%end;
|
|
119
133
|
%else %if &platform=SASVIYA %then %do;
|
|
120
|
-
filename
|
|
134
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
|
121
135
|
contenttype=
|
|
122
136
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
123
137
|
contentdisp="attachment; filename=&outname";
|
|
@@ -131,17 +145,20 @@ run;
|
|
|
131
145
|
run;
|
|
132
146
|
%end;
|
|
133
147
|
%else %if &platform=SASVIYA %then %do;
|
|
134
|
-
filename
|
|
148
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
|
135
149
|
contenttype='application/zip'
|
|
136
150
|
contentdisp="attachment; filename=&outname";
|
|
137
151
|
%end;
|
|
138
152
|
%end;
|
|
153
|
+
%else %do;
|
|
154
|
+
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
|
155
|
+
%end;
|
|
139
156
|
|
|
140
157
|
%if &inref ne 0 %then %do;
|
|
141
|
-
%mp_binarycopy(inref=&inref,outref
|
|
158
|
+
%mp_binarycopy(inref=&inref,outref=&outref)
|
|
142
159
|
%end;
|
|
143
160
|
%else %do;
|
|
144
|
-
%mp_binarycopy(inloc="&inloc",outref
|
|
161
|
+
%mp_binarycopy(inloc="&inloc",outref=&outref)
|
|
145
162
|
%end;
|
|
146
163
|
|
|
147
164
|
%mend mp_streamfile;
|
package/package.json
CHANGED