cancel
Showing results for 
Search instead for 
Did you mean: 

WebIDE Create new file

Former Member
0 Kudos
89

HI,

Which API should I use in order to create/generate new file in the WebIDE ?

I've content which I want to put inside generated file.

my project is build like

myProj

    folderA

        fileA

    FolderB

        fileB

Lest assume that I need to create new html file inside folderA.

Which services I need to use ?

i've the

service.filesystem.documentProvider

I saw the service but not sure if it is the right service and how to use it inside my project for specific folder

oFolderDocument.importFile(new Blob([ my  content])

Example will be very helpful

Message was edited by: Stephane Singler

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,

First you've to create a file by:

oFolderDocument.createFile(sFileName) which return a promise.

Now you have a new empty file and you can set the content of the file and save it.

Your code should look like:


oFolderDocument.createFile(sFileName).then(function(oFile){

  return oFile.setContent(sContent).then(function(){

       return oFile.save();

   });

}).done();

HTH,

Lidor

Answers (2)

Answers (2)

Former Member
0 Kudos

just Right click on folderA New->File give filename as <yourfilename>.<ext>

Former Member
0 Kudos

HI,

Well, As I write I dont want to create it manually ...I need the API.

Regards,

Stephane

michal_keidar
Employee
Employee
0 Kudos

Hi , can you assist?

Thanks,
Michal.