Skip to content

STOR.js reply(150) before waitForConnection #303

Answered by ideadesignmedia
inkeytech asked this question in Q&A
Discussion options

You must be logged in to vote

Figured it out:

const Promise = require('bluebird');

module.exports = {
  directive: 'STOR',
  handler: function ({log, command} = {}) {
    if (!this.fs) return this.reply(550, 'File system not instantiated');
    if (!this.fs.write) return this.reply(402, 'Not supported by file system');

    const append = command.directive === 'APPE';
    const fileName = command.arg;
	this.reply(150).then(() => this.connector.socket && this.connector.socket.resume())
    return this.connector.waitForConnection()
    .tap(() => this.commandSocket.pause())
    .then(() => Promise.try(() => this.fs.write(fileName, {append, start: this.restByteCount})))
    .then((fsResponse) => {
      let {stream, cli…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@matt-forster
Comment options

@inkeytech
Comment options

@matt-forster
Comment options

@inkeytech
Comment options

@matt-forster
Comment options

Answer selected by matt-forster
Comment options

You must be logged in to vote
2 replies
@ideadesignmedia
Comment options

@inkeytech
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #302 on May 20, 2022 23:00.