cocoanut
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Error “Could not write file wpid-m (Invalid file type)Ahh. Thats what it is.
Hmm… I have no idea how to change that through AppleScript.
Thank you for your assistance, Joseph.
I’ll hit the AppleScript forum and see if there is a solution there.
Forum: Fixing WordPress
In reply to: Error “Could not write file wpid-m (Invalid file type)I have mode some progress on this issue. By Joseph providing the arguments list, it prompted me to reconsider the way I was passing the file_data parameters. I changed the code to form a structure in AppleScript.
on run {input, parameters} set myUsername to "myusername" set myPassword to "mypassword" set parameterStruct to {|name|:"imagename.jpg", type:"image/jpeg", bits:input, overwrite:true} tell application "https://twih.kamboville.com/xmlrpc.php" set returnValue to call xmlrpc {method name:"wp.uploadFile", parameters:{1, myUsername, myPassword, parameterStruct}} end tell return returnValue end run
The code runs successfully, something is uploaded. Unfortunately, the file name uploaded is prepended with “wpid-“. So the file name is now “wpid-imagename.jpg” and there is a question mark in place of the actual image.
The returnValue is
{|file|:"wpid-imagename.jpg", |url|:"https://mywordpresssite.com/wp-content/uploads/wpid-imagename.jpg", type:"image/jpeg"}
Which is very strange considering the filename I’m passing is “imagename.jpg”.
I used a packet sniffer to capture the XML file being sent to the server. Not sure if this is what it should be.
<?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>wp.uploadFile</methodName> <params> <param> <value> <i4>1</i4> </value> </param> <param> <value> <string>myusername</string> </value> </param> <param> <value> <string>mypassword</string> </value> </param> <param> <value> <struct> <member> <name>name</name> <value> <string>imagename.jpg</string> </value> </member> <member> <name>type</name> <value> <string>image/jpeg</string> </value> </member> <member> <name>bits</name> <value> <array> <data> <value> <string>/9j/4AAQSkZJRgABAAEAYABgAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCEAAgFBgcGBQgHBgcJCAgJDBQNDAsLDBgREg4UHRkeHhwZHBsgJC4nICIrIhscKDYoKy8xMzQzHyY4PDgyPC4yMzEBCAkJDAoMFw0NFzEhHCExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMf/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEAA @@ LOTS MORE FUNNY CHARACTERS HERE @@ lXJXbWqOaauyfUVENs7xkqwOM1EK89NSIwXNYyG1C7B2idsHPp6V3JnSqULbEbzzyrLumcFY2cEYzkLms6s5Ri2i6dKHMlYyNQvroWmnt57Zlg3vwOTuI9K8N47ERtaR6ccNSi3aJPFI82js0rbmWcAE9cbaSr1Kq993IlCMNYohT09KRmzWtLuVbGNGPmKZCu1+RjFa9GZS3HXthAFV0BQnqAeKqyauTKbjsf/9k=</string> </value> </data> </array> </value> </member> <member> <name>overwrite</name> <value> <boolean>1</boolean> </value> </member> </struct> </value> </param> </params> </methodCall>
Forum: Fixing WordPress
In reply to: Error “Could not write file wpid-m (Invalid file type)Hi Joseph,
Yes, I am able to upload normally via wp-admin
I’m not sure if I’m forming the parameters correctly. Is there something I need to specifically pass along that denotes a file_data struct? Do I have the fileType correct or should I be passing “image/jpeg” instead of “JPEG” ? I have tried both in anyway and I receive the same error message.