mirror of
https://github.com/sasjs/core.git
synced 2026-01-09 02:10:06 +00:00
fix: enabling reading from / writing to SAS Drive. Closes #334
This commit is contained in:
@@ -41,7 +41,7 @@ run;
|
|||||||
desc=Check if created file exists
|
desc=Check if created file exists
|
||||||
)
|
)
|
||||||
|
|
||||||
%put TEST 2 - dataset upload ;
|
%put TEST 3 - dataset upload ;
|
||||||
data temp;
|
data temp;
|
||||||
x=1;
|
x=1;
|
||||||
run;
|
run;
|
||||||
@@ -52,4 +52,27 @@ filename ds "%sysfunc(pathname(work))/temp.sas7bdat";
|
|||||||
%mp_assert(
|
%mp_assert(
|
||||||
iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..sas7bdat)=1),
|
iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..sas7bdat)=1),
|
||||||
desc=Check if created dataset exists
|
desc=Check if created dataset exists
|
||||||
)
|
)
|
||||||
|
|
||||||
|
%put TEST 4 - create a .sas file;
|
||||||
|
filename f4 temp;
|
||||||
|
data _null_;
|
||||||
|
file f4;
|
||||||
|
put '%put hello FromSASStudioBailey; ';
|
||||||
|
run;
|
||||||
|
%mv_createfile(path=&mcTestAppLoc/temp, name=test4.sas,inref=f4,mdebug=1)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..sas)=1),
|
||||||
|
desc=Check if created sas program exists
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%put TEST 5 - reading from files service and writing back;
|
||||||
|
filename sendfrom filesrvc folderpath="&mcTestAppLoc/temp" filename='test4.sas';
|
||||||
|
|
||||||
|
OPTIONS MERROR SYMBOLGEN MLOGIC MPRINT;
|
||||||
|
|
||||||
|
%mv_createfile(path=&mcTestAppLoc/temp,name=test5.sas,inref=sendfrom,mdebug=1) ;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
@li BINARY File is copied byte for byte using the mp_binarycopy.sas macro.
|
@li BINARY File is copied byte for byte using the mp_binarycopy.sas macro.
|
||||||
@li BASE64 File will be first decoded using the mp_base64.sas macro, then
|
@li BASE64 File will be first decoded using the mp_base64.sas macro, then
|
||||||
loaded byte by byte to SAS Drive.
|
loaded byte by byte to SAS Drive.
|
||||||
@param [in] contentdisp= Content Disposition. Example values:
|
@param [in] contentdisp= (attchment) Content Disposition. Example values:
|
||||||
@li inline
|
@li inline
|
||||||
@li attachment
|
@li attachment
|
||||||
@param [in] ctype= (0) The actual MIME type of the file (if blank will be
|
@param [in] ctype= (0) The actual MIME type of the file (if blank will be
|
||||||
@@ -48,7 +48,6 @@
|
|||||||
@li mf_mimetype.sas
|
@li mf_mimetype.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
@li mp_base64copy.sas
|
@li mp_base64copy.sas
|
||||||
@li mp_binarycopy.sas
|
|
||||||
@li mv_createfolder.sas
|
@li mv_createfolder.sas
|
||||||
|
|
||||||
<h4> Related Macros</h4>
|
<h4> Related Macros</h4>
|
||||||
@@ -60,7 +59,7 @@
|
|||||||
,name=
|
,name=
|
||||||
,inref=
|
,inref=
|
||||||
,intype=BINARY
|
,intype=BINARY
|
||||||
,contentdisp=
|
,contentdisp=attachment
|
||||||
,ctype=0
|
,ctype=0
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
@@ -104,9 +103,7 @@
|
|||||||
%local fref;
|
%local fref;
|
||||||
%let fref=%mf_getuniquefileref();
|
%let fref=%mf_getuniquefileref();
|
||||||
|
|
||||||
%if %upcase(&intype)=BINARY %then %do;
|
%if %upcase(&intype)=BINARY %then %let fref=&inref;
|
||||||
%mp_binarycopy(inref=&inref, outref=&fref)
|
|
||||||
%end;
|
|
||||||
%else %if %upcase(&intype)=BASE64 %then %do;
|
%else %if %upcase(&intype)=BASE64 %then %do;
|
||||||
%mp_base64copy(inref=&inref, outref=&fref, action=DECODE)
|
%mp_base64copy(inref=&inref, outref=&fref, action=DECODE)
|
||||||
%end;
|
%end;
|
||||||
@@ -141,18 +138,26 @@ options noquotelenmax;
|
|||||||
%local base_uri; /* location of rest apis */
|
%local base_uri; /* location of rest apis */
|
||||||
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
||||||
|
|
||||||
|
%local url mimetype;
|
||||||
|
%let url=&base_uri/files/files?parentFolderUri=&self_uri;
|
||||||
|
|
||||||
/* fetch job info */
|
/* fetch job info */
|
||||||
%local fname1;
|
%local fname1;
|
||||||
%let fname1=%mf_getuniquefileref();
|
%let fname1=%mf_getuniquefileref();
|
||||||
proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
||||||
%if "&ctype" = "0" %then %do;
|
%if "&ctype" = "0" %then %do;
|
||||||
ct="%mf_mimetype(%scan(&name,-1,.))"
|
%let mimetype=%mf_mimetype(%scan(&name,-1,.));
|
||||||
|
ct="&mimetype"
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
ct="&ctype"
|
ct="&ctype"
|
||||||
%end;
|
%end;
|
||||||
url="&base_uri/files/files?parentFolderUri=&self_uri%str(&)typeDefName=file";
|
%if "&mimetype"="text/html" %then %do;
|
||||||
|
url="&url%str(&)typeDefName=file";
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
url="&url";
|
||||||
|
%end;
|
||||||
|
|
||||||
headers "Accept"="application/json"
|
headers "Accept"="application/json"
|
||||||
%if &grant_type=authorization_code %then %do;
|
%if &grant_type=authorization_code %then %do;
|
||||||
@@ -178,9 +183,9 @@ data &outds;
|
|||||||
end;
|
end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
%local mfv_getpathurivar=%mfv_getpathuri(&path/&name);
|
||||||
%put &sysmacroname: File &name successfully created:;%put;
|
%put &sysmacroname: File &name successfully created:;%put;
|
||||||
%put &base_uri%mfv_getpathuri(&path/&name);%put;
|
%put &base_uri&mfv_getpathurivar;%put;
|
||||||
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
||||||
%put &sysmacroname:;
|
%put &sysmacroname:;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user