diff --git a/all.sas b/all.sas index 6f17814..036b596 100644 --- a/all.sas +++ b/all.sas @@ -18854,6 +18854,38 @@ run; ) %mend ms_createfile; +/** + @file + @brief Gets a file from SASjs Drive + @details Fetches a file on SASjs Drive and stores it in the output fileref. + + Example: + + %ms_getfile(/some/stored/file.ext, outref=myfile) + + @param [in] driveloc The full path to the file in SASjs Drive + @param [out] outref= (msgetfil) The fileref to contain the file. + @param [in] mdebug= (0) Set to 1 to enable DEBUG messages + + +**/ + +%macro ms_getfile(driveloc + ,outref=msgetfil + ,mdebug=0 + ); + +filename &outref temp; + +proc http method='GET' out=&outref + url="&_sasjs_apiserverurl/SASjsApi/drive/file?filePath=&driveloc"; +%if &mdebug=1 %then %do; + debug level=2; +%end; +run; + + +%mend ms_getfile; /** @file @brief Executes a SASjs Server Stored Program diff --git a/server/ms_getfile.sas b/server/ms_getfile.sas new file mode 100644 index 0000000..8041641 --- /dev/null +++ b/server/ms_getfile.sas @@ -0,0 +1,32 @@ +/** + @file + @brief Gets a file from SASjs Drive + @details Fetches a file on SASjs Drive and stores it in the output fileref. + + Example: + + %ms_getfile(/some/stored/file.ext, outref=myfile) + + @param [in] driveloc The full path to the file in SASjs Drive + @param [out] outref= (msgetfil) The fileref to contain the file. + @param [in] mdebug= (0) Set to 1 to enable DEBUG messages + + +**/ + +%macro ms_getfile(driveloc + ,outref=msgetfil + ,mdebug=0 + ); + +filename &outref temp; + +proc http method='GET' out=&outref + url="&_sasjs_apiserverurl/SASjsApi/drive/file?filePath=&driveloc"; +%if &mdebug=1 %then %do; + debug level=2; +%end; +run; + + +%mend ms_getfile; diff --git a/tests/serveronly/ms_getfile.test.sas b/tests/serveronly/ms_getfile.test.sas new file mode 100644 index 0000000..a32ceab --- /dev/null +++ b/tests/serveronly/ms_getfile.test.sas @@ -0,0 +1,45 @@ +/** + @file + @brief Testing ms_getfile.sas macro + +