-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: append service, provides backend functionality towards #9
- Loading branch information
Allan Bowe
committed
Aug 24, 2021
1 parent
14b1269
commit 7ba0b63
Showing
3 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
@file | ||
@brief appends a file from frontend to a user provided location | ||
@details Returns the file size or -1 in case of error. | ||
<h4> SAS Macros </h4> | ||
@li mf_getfilesize.sas | ||
@li mf_isdir.sas | ||
@li mp_abort.sas | ||
@li mp_binarycopy.sas | ||
**/ | ||
|
||
%mp_abort(iftrue= (%mf_isdir(&path) = 0) | ||
,mac=&_program..sas | ||
,msg=%str(File path (&path) is not a valid directory) | ||
) | ||
|
||
/* | ||
Grab the file uri. IF there are multiple, they are numbered, so | ||
placeholder logic is provided for convenience. | ||
*/ | ||
%global _webin_fileuri _webin_fileuri1 _webin_filename _webin_filename1; | ||
%let infile=%sysfunc(coalescec(&_webin_fileuri1,&_webin_fileuri)); | ||
%let outfile=%sysfunc(coalescec(&_webin_filename1,&_webin_filename)); | ||
|
||
/* read in the file from the file service */ | ||
filename filein filesrvc "&infile"; | ||
filename fileout "&path/&outfile"; | ||
|
||
%mp_binarycopy(inref=filein, outref=fileout, mode=APPEND) | ||
|
||
%mp_abort(iftrue= (&syscc ge 4) | ||
,mac=&_program..sas | ||
,msg=%str(Error occurred whilst reading &infile and writing to &outfile ) | ||
) | ||
|
||
/* success - lets create a directory listing */ | ||
data fromsas; | ||
filesize="%mf_getfilesize(fpath=&path/&outfile,format=yes)"; | ||
run; | ||
|
||
/* now send it back to the frontend */ | ||
%webout(OPEN) | ||
%webout(OBJ,fromsas) | ||
%webout(CLOSE) |