MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / createFile

Method createFile

src/fileSystem/sftp.js:104–130  ·  view source on GitHub ↗

* * @param {String} filename * @param {String} content

(filename, content)

Source from the content-addressed store, hash-verified

102 * @param {String} content
103 */
104 createFile(filename, content) {
105 filename = Path.join(this.#path, filename);
106 return new Promise((resolve, reject) => {
107 sftp.isConnected((connectionID) => {
108 (async () => {
109 if (this.#notConnected(connectionID)) {
110 try {
111 await this.connect();
112 } catch (error) {
113 reject(error);
114 return;
115 }
116 }
117 sftp.createFile(
118 filename,
119 content ? content : "",
120 async (_res) => {
121 resolve(Url.join(this.#base, filename));
122 },
123 (err) => {
124 reject(err);
125 },
126 );
127 })();
128 });
129 });
130 }
131
132 /**
133 *

Callers

nothing calls this directly

Calls 5

#notConnectedMethod · 0.95
connectMethod · 0.95
resolveFunction · 0.85
isConnectedMethod · 0.65
createFileMethod · 0.65

Tested by

no test coverage detected