I need to upload a file from my local disk to a SAS Content folder. I am using the SAS REST APIs for this.
I am a bit confused reading the API doc on https://developers.sas.com. On the one hand in the "folders" API there is an option to add a "member" to an existing folder. On the other hand, on the "files" API there is an option to create a new file. Not sure what to use and what is the relationship between the two.. Any advice?
Hi @EyalGonen,
You can use the Upload a file end point under the dataTables API. I'm attaching a Postman collection with example usage. Look in step 2. upload data for an example.
Join us for SAS Community Trivia
Hi @joeFurbee
I need to upload text files such SAS programs or binary files like JPG files. Is your solution appropriate for these use cases?
Hi @EyalGonen,
Yes, a text file should be fine. In my example (see below) I use a csv file. In order to provide the file path, I went to the Body section, created a new file Key and provided the path from my client as the Value.
I've not tried with .jpg. Would be interested if that works or not.
Join us for SAS Community Trivia
Sorry for the (very) late reply...
I just came back to this (doing it on my free time) and I am using this API: https://developer.sas.com/rest-apis/files/createNewFile to upload local client files to the SAS Files service and in addition I am passing the parentFolderUri parameter as explained here https://developer.sas.com/rest-apis/files/createNewFile#query-parameters to attach the uploaded file to some SAS Content folder.
This works BUT I cannot find a way to specify the filename to be displayed in the SAS Content folder. The uploaded file appears in the SAS Content folder with this name: FileResource1779021791076 where the digits are changing with each file I upload.
I am testing on Viya 3.5 so maybe it is different for SAS Viya.
Any idea how to control the uploaded filename as seen in the SAS Content folder?
Hi @gwootton
Thanks! It works now!
I have one more question about the query parameter "typeDefName" here: https://developer.sas.com/rest-apis/files/createNewFile#query-parameters.
Where can I find the possible values for this parameter?
All files I uploaded are with type="file" in SAS Content and I want to change at least for SAS programs.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →