0

I'll start by saying I have programming experience from a classroom setting and and can read and write code, but I don't do it on a daily basis.

However, I'm looking to upload multiple image files to OneDrive using Python or Javascript via Zapier. My input is a string of URLs, separated by commas that are direct download links to these image files. I want to loop through each one and upload it to OneDrive. Has anyone done something like this or do you have suggestions on where I should start?

Thanks in advance! -DLMN

DLMN
  • 1
  • Hey DLMN, could you share some more details concerning what you have attempted so far? What is the template of workflow you are trying to build (i.e. What are you using as a trigger zap, what action steps do you require). Take a look at the answer I posted to a similar question: https://stackoverflow.com/questions/52982304/zapier-to-create-multiple-rows-in-google-sheet-from-tsheets-data/52999676#52999676 You should be able to adapt this template to match your needs. – Michael Case Apr 14 '19 at 01:46
  • Thanks Michael - I hadn't tried much of anything at the point of this post. I was just looking for general input. At this point I have something similar coded, as this is what Zapier support recommended. My only issue is OneDrive doesn't accept multiple file uploads, so I'm trying to split the multiple links I get from our GoCanvas form to separate Zaps, so I can upload each photo to OneDrive individually. -DLMN – DLMN Apr 15 '19 at 16:04
  • Welcome to StackOverflow! Keep in mind this is a place where programming amateurs and professionals help each other on their down time. Questions where people ask for someone to do something for them are generally frowned upon and don't receive many answers. Instead, show some code of what you've tried and where you're stuck. – Domino Apr 16 '19 at 21:24

1 Answers1

0

If I have understood your requirements correctly the following should work:

I am going to make the assumption you have already setup your trigger step which is where you are getting the list of download URLs. The following action step should then be a code step which takes this string of URLs as input.

The code step will act as a staging area to prepare output to the final OneDrive action step which will handle the uploading.

In the code step you will need to isolate the individual URLs. If the list of URLs is in a string presumably they are comma delimited. You can store each individual URL in a list using Python's split() function:

url_list = input_data.get("url_list").split(",")

You will need to return a dictionary object in order to use the output in your final OneDrive step, but you want to execute your final step on a list of inputs. So you will need to return a list of dictionary objects. You can do something like the following:

output_list = []
for url in url_list:
    ouput_list.append({"url" : url})

And finally return the output_list

Because you are returning a list the following code step will execute for each item within the list. Because the list contains dictionary objects they will be mapped as url : "someuploadurl" in your following steps. This should allow you to upload multiple files to OneDrive for a given list of URLs.

Further explanation can be found in this answer as well.
Take a look at Zapier's code documentation if you need clarification for getting input from trigger steps into your code step.

Michael Case
  • 508
  • 4
  • 13