Your best friend for file transfer.

Fetch application logoFetch

Changing chmod permissions in upload droplet (3 posts)

  • Started 18 years ago by TomK
  • Latest reply 18 years ago from TomK
  • TomK Member

    I constructed a script that will upload files to my server when I drop them on the following Applescript droplet. However, for some reason, my server sets the chmod permissions on the newly uploaded files to 600 rather than the needed 644.

    on open these_items
    set myuser to "myuser"
    set mypass to "mypass"
    set myhost to "myhost"
    set mypath to "/mypath/"
    set destUrl to "sftp://" & myuser & ":" & mypass & "@" & myhost & mypath
    tell application "Fetch"
    activate
    with timeout of 300 seconds
    put into url destUrl item these_items
    -- set permissions of remote files in destUrl to 644
    end timeout
    end tell
    end open

    I couldn't find a setting in Fetch -- please point it out to me if I missed it -- to change this automatically to 644, so my idea was to try to automate the upload to change it. In the above, the commented out "set permissions" line was my first stab at it. It didn't work.

    My next stab was as below, which also doesn't work.

    tell application "Fetch"
    activate
    with timeout of 300 seconds
    repeat with this_item in these_items
    put into url destUrl item this_item
    set dest_item to destUrl & this_item
    set permissions of remote file in dest_item to 644
    end repeat
    end timeout
    end tell

    Am I on the right track? Is this even doable or do I have to go back and edit permissions by hand?

    TomK

    Posted 18 years ago #

  • Jim Matthews Administrator

    You're on the right track, the script just needs a tweak. The trick is to use the "info for" command from the standard scripting additions to get the name of the file being uploaded. Then you can use that to build the URL of the newly uploaded file:

    on open these_items
    set myuser to "myuser"
    set mypass to "mypass"
    set myhost to "myhost"
    set mypath to "/mypath/"
    set destUrl to "sftp://" & myuser & ":" & mypass & "@" & myhost & mypath
    with timeout of 300 seconds
    repeat with this_item in these_items
    -- first upload the file
    tell application "Fetch"
    put into url destUrl item this_item
    end tell

    -- now figure out its URL
    set this_info to info for this_item
    set this_name to name of this_info
    set dest_item_url to destUrl & this_name

    -- now set its permissions
    tell application "Fetch"
    set permissions of url dest_item_url to 644
    end tell
    end repeat
    end timeout
    end open

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 18 years ago #

  • TomK Member

    Interesting. I wouldn't have figured out that I had to build the url outside of Fetch. Thanks so much. That worked great.

    repeat with this_item in these_items
    -- first upload the file
    tell application "Fetch"
    put into url destUrl item this_item
    end tell

    -- now figure out its URL
    set this_info to info for this_item
    set this_name to name of this_info
    set dest_item_url to destUrl & this_name

    -- now set its permissions
    tell application "Fetch"
    set permissions of url dest_item_url to 644
    end tell
    end repeat

    [This message has been edited by TomK (edited 10-10-2005).]

    [This message has been edited by TomK (edited 10-10-2005).]

    Posted 18 years ago #

Reply

  • Or nickname, if you prefer.
  • This will be kept confidential.
  • This is to ensure that you’re a person, not a spambot.