(data: string, options: OptionValues)
| 316 | } |
| 317 | |
| 318 | private makeSendJson(data: string, options: OptionValues) { |
| 319 | let sendFile = null; |
| 320 | let sendText = null; |
| 321 | let name = Utils.newGuid(); |
| 322 | let type: SendType = SendType.Text; |
| 323 | if (options.file != null) { |
| 324 | data = path.resolve(data); |
| 325 | if (!fs.existsSync(data)) { |
| 326 | return Response.badRequest("data path does not exist"); |
| 327 | } |
| 328 | |
| 329 | sendFile = SendFileResponse.template(data); |
| 330 | name = path.basename(data); |
| 331 | type = SendType.File; |
| 332 | } else { |
| 333 | sendText = SendTextResponse.template(data, options.hidden); |
| 334 | } |
| 335 | |
| 336 | const template = Utils.assign(SendResponse.template(null, options.deleteInDays), { |
| 337 | name: options.name ?? name, |
| 338 | notes: options.notes, |
| 339 | file: sendFile, |
| 340 | text: sendText, |
| 341 | type: type, |
| 342 | emails: options.emails ?? undefined, |
| 343 | }); |
| 344 | |
| 345 | return Buffer.from(JSON.stringify(template), "utf8").toString("base64"); |
| 346 | } |
| 347 | |
| 348 | private async runCreate(encodedJson: string, options: OptionValues) { |
| 349 | await this.exitIfLocked(); |
no test coverage detected