@sasjs/core 4.3.2 → 4.4.3
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_ds2csv.sas +2 -2
- package/base/mp_streamfile.sas +52 -36
- package/package.json +1 -1
package/base/mp_ds2csv.sas
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
numbers).
|
|
50
50
|
@param [out] outfile= The output filename - should be quoted.
|
|
51
51
|
@param [out] outref= (0) The output fileref (takes precedence if provided)
|
|
52
|
-
@param [in] outencoding= (0) The output encoding to use
|
|
52
|
+
@param [in] outencoding= (0) The (quoted) output encoding to use, eg `"UTF-8"`
|
|
53
53
|
@param [in] termstr= (CRLF) The line seperator to use. For SASJS, will
|
|
54
54
|
always be CRLF. Valid values:
|
|
55
55
|
@li CRLF
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
%if %index(&ds,.)=0 %then %let ds=WORK.&ds;
|
|
86
86
|
|
|
87
87
|
%if &outencoding=0 %then %let outencoding=;
|
|
88
|
-
%else %let outencoding=encoding
|
|
88
|
+
%else %let outencoding=encoding=&outencoding;
|
|
89
89
|
|
|
90
90
|
%if &outref=0 %then %let outloc=&outfile;
|
|
91
91
|
%else %let outloc=&outref;
|
package/base/mp_streamfile.sas
CHANGED
|
@@ -12,17 +12,19 @@
|
|
|
12
12
|
|
|
13
13
|
%mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
|
|
14
14
|
|
|
15
|
+
@param [in] contenttype= (TEXTS) Either TEXT, ZIP, CSV, EXCEL
|
|
16
|
+
@param [in] inloc= /path/to/file.ext to be sent
|
|
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.
|
|
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.
|
|
22
|
+
|
|
15
23
|
<h4> SAS Macros </h4>
|
|
16
24
|
@li mf_getplatform.sas
|
|
17
25
|
@li mp_binarycopy.sas
|
|
18
26
|
|
|
19
|
-
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
|
20
|
-
@param inloc= /path/to/file.ext to be sent
|
|
21
|
-
@param inref= fileref of file to be sent (if provided, overrides `inloc`)
|
|
22
|
-
@param outname= the name of the file, as downloaded by the browser
|
|
23
|
-
|
|
24
27
|
@author Allan Bowe
|
|
25
|
-
@source https://github.com/sasjs/core
|
|
26
28
|
|
|
27
29
|
**/
|
|
28
30
|
|
|
@@ -30,13 +32,17 @@
|
|
|
30
32
|
contenttype=TEXT
|
|
31
33
|
,inloc=
|
|
32
34
|
,inref=0
|
|
35
|
+
,iftrue=%str(1=1)
|
|
33
36
|
,outname=
|
|
37
|
+
,outref=_webout
|
|
34
38
|
)/*/STORE SOURCE*/;
|
|
35
39
|
|
|
40
|
+
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
41
|
+
|
|
36
42
|
%let contentype=%upcase(&contenttype);
|
|
43
|
+
%let outref=%upcase(&outref);
|
|
37
44
|
%local platform; %let platform=%mf_getplatform();
|
|
38
45
|
|
|
39
|
-
|
|
40
46
|
/**
|
|
41
47
|
* check engine type to avoid the below err message:
|
|
42
48
|
* > Function is only valid for filerefs using the CACHE access method.
|
|
@@ -44,20 +50,20 @@
|
|
|
44
50
|
%local streamweb;
|
|
45
51
|
%let streamweb=0;
|
|
46
52
|
data _null_;
|
|
47
|
-
set sashelp.vextfl(where=(upcase(fileref)="
|
|
53
|
+
set sashelp.vextfl(where=(upcase(fileref)="&outref"));
|
|
48
54
|
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
|
49
55
|
run;
|
|
50
56
|
|
|
51
|
-
%if &contentype=
|
|
57
|
+
%if &contentype=CSV %then %do;
|
|
52
58
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
53
59
|
data _null_;
|
|
54
|
-
rc=stpsrv_header('Content-type','application/
|
|
60
|
+
rc=stpsrv_header('Content-type','application/csv');
|
|
55
61
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
56
62
|
run;
|
|
57
63
|
%end;
|
|
58
64
|
%else %if &platform=SASVIYA %then %do;
|
|
59
|
-
filename
|
|
60
|
-
contenttype='application/
|
|
65
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
66
|
+
contenttype='application/csv'
|
|
61
67
|
contentdisp="attachment; filename=&outname";
|
|
62
68
|
%end;
|
|
63
69
|
%end;
|
|
@@ -70,68 +76,78 @@ run;
|
|
|
70
76
|
run;
|
|
71
77
|
%end;
|
|
72
78
|
%else %if &platform=SASVIYA %then %do;
|
|
73
|
-
filename
|
|
79
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
|
74
80
|
contenttype='application/vnd.ms-excel'
|
|
75
81
|
contentdisp="attachment; filename=&outname";
|
|
76
82
|
%end;
|
|
77
83
|
%end;
|
|
78
|
-
%else %if &contentype=
|
|
84
|
+
%else %if &contentype=HTML %then %do;
|
|
85
|
+
%if &platform=SASVIYA %then %do;
|
|
86
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
|
87
|
+
contenttype="text/html";
|
|
88
|
+
%end;
|
|
89
|
+
%end;
|
|
90
|
+
%else %if &contentype=TEXT %then %do;
|
|
79
91
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
80
92
|
data _null_;
|
|
81
|
-
rc=stpsrv_header('Content-type',
|
|
82
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
93
|
+
rc=stpsrv_header('Content-type','application/text');
|
|
83
94
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
84
95
|
run;
|
|
85
96
|
%end;
|
|
86
97
|
%else %if &platform=SASVIYA %then %do;
|
|
87
|
-
filename
|
|
88
|
-
contenttype=
|
|
89
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
98
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
99
|
+
contenttype='application/text'
|
|
90
100
|
contentdisp="attachment; filename=&outname";
|
|
91
101
|
%end;
|
|
92
102
|
%end;
|
|
93
|
-
%else %if &contentype=
|
|
103
|
+
%else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
|
|
94
104
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
95
105
|
data _null_;
|
|
96
|
-
rc=stpsrv_header('Content-type',
|
|
97
|
-
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
106
|
+
rc=stpsrv_header('Content-type',"font/%lowcase(&contenttype)");
|
|
98
107
|
run;
|
|
99
108
|
%end;
|
|
100
109
|
%else %if &platform=SASVIYA %then %do;
|
|
101
|
-
filename
|
|
102
|
-
contenttype=
|
|
103
|
-
contentdisp="attachment; filename=&outname";
|
|
110
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
111
|
+
contenttype="font/%lowcase(&contenttype)";
|
|
104
112
|
%end;
|
|
105
113
|
%end;
|
|
106
|
-
%else %if &contentype=
|
|
114
|
+
%else %if &contentype=XLSX %then %do;
|
|
107
115
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
108
116
|
data _null_;
|
|
109
|
-
rc=stpsrv_header('Content-type',
|
|
117
|
+
rc=stpsrv_header('Content-type',
|
|
118
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
110
119
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
111
120
|
run;
|
|
112
121
|
%end;
|
|
113
122
|
%else %if &platform=SASVIYA %then %do;
|
|
114
|
-
filename
|
|
115
|
-
contenttype=
|
|
123
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
|
124
|
+
contenttype=
|
|
125
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
116
126
|
contentdisp="attachment; filename=&outname";
|
|
117
127
|
%end;
|
|
118
128
|
%end;
|
|
119
|
-
%else %if &contentype=
|
|
120
|
-
%if &platform=
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
%else %if &contentype=ZIP %then %do;
|
|
130
|
+
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
131
|
+
data _null_;
|
|
132
|
+
rc=stpsrv_header('Content-type','application/zip');
|
|
133
|
+
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
134
|
+
run;
|
|
135
|
+
%end;
|
|
136
|
+
%else %if &platform=SASVIYA %then %do;
|
|
137
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
|
138
|
+
contenttype='application/zip'
|
|
139
|
+
contentdisp="attachment; filename=&outname";
|
|
123
140
|
%end;
|
|
124
141
|
%end;
|
|
125
142
|
%else %do;
|
|
126
143
|
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
|
127
|
-
%return;
|
|
128
144
|
%end;
|
|
129
145
|
|
|
130
146
|
%if &inref ne 0 %then %do;
|
|
131
|
-
%mp_binarycopy(inref=&inref,outref
|
|
147
|
+
%mp_binarycopy(inref=&inref,outref=&outref)
|
|
132
148
|
%end;
|
|
133
149
|
%else %do;
|
|
134
|
-
%mp_binarycopy(inloc="&inloc",outref
|
|
150
|
+
%mp_binarycopy(inloc="&inloc",outref=&outref)
|
|
135
151
|
%end;
|
|
136
152
|
|
|
137
153
|
%mend mp_streamfile;
|
package/package.json
CHANGED