Skip to content

overwrite not working on client.uploadFile #54

Description

@mautematico

Take this sample code:

const WordPress = require( "wordpress" );
const fs = require('fs');

const client = WordPress.createClient({
	url:		"url",
	username:	"username",
	password:	"password"
});

let file = fs.readFileSync(`/tmp/16508471_379760699056052_625556649633729067_n.jpg`);

let uploadOptions = {
	name: '16508471_379760699056052_625556649633729067_n.jpg',
        type: 'image/jpeg',
	bits: file,
    overwrite: true
};

client.uploadFile(uploadOptions, function (error, fileData) {
    console.log(fileData.attachment_id); //new ID on every upload
    console.log(fileData.metadata.file); //new file path (appending -number) on every upload
    console.log(fileData.file); //same as uploadOptions.name
});

uploadOptions.overwrite is true. Anyway, a new (duplicated) file will be created on every run.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions