Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overwrite not working on client.uploadFile #54

Open
mautematico opened this issue Feb 25, 2017 · 0 comments
Open

overwrite not working on client.uploadFile #54

mautematico opened this issue Feb 25, 2017 · 0 comments

Comments

@mautematico
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant