Skip to main content
Question

Shared Links API

  • May 21, 2025 12:27 PM UTC
  • 21 replies
  • 102 views
  • Translate All

Forum|alt.badge.img

Is it possible to generate shared links for all files contained in a specific folder through the API? Thanks in advance!

21 replies

Forum|alt.badge.img

here's a box-java-sdk example...

 

BoxDeveloperEditionAPIConnection userApi = BoxDeveloperEditionAPIConnection.getAppUserConnection(managedUser.getID(), CLIENT_ID, CLIENT_SECRET, encryptionPref, accessTokenCache);

BoxFolder boxFolder = new BoxFolder(userApi, "");

BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);

Iterable items = boxFolder.getChildren();
for (BoxItem.Info item : items) {
    if (item instanceof BoxFile.Info) {
       BoxFile.Info fileInto = (BoxFile.Info) item;
       BoxFile file = new BoxFile(userApi, fileInto.getID());
       file.createSharedLink(BoxSharedLink.Access.OPEN, null, permissions);
    }   
}
Translate

Forum|alt.badge.img

Thank you for that. I'm not familiar with the Java SDK, but I'll try and fumlbe through it. 

Translate

Forum|alt.badge.img

A follow-up question. First is there an example of this in python?

 

Second is there a way to generate custom URLs for share links in the API?

Translate

Forum|alt.badge.img

Hello what are the steps and how i can do this? i really need this! 

 

Thanks

Translate

Forum|alt.badge.img

I've built out a jar file to do this. doing some debugging but can share when complete. 

Translate

Forum|alt.badge.img

more or less when would you be complete with this? lol hope you can make this happen!

Translate

Forum|alt.badge.img

any luck using that code?

Translate

Forum|alt.badge.img

Yes! Code takes a whole folder, and generates shared links for each file present and dumps to a csv file. I had some help because some of its above my pay grade. had a friend add multi threading too. It works but needs a little more debugging due to authentication with box. hopefully wrap it up this week. 

Translate

Forum|alt.badge.img

Great! Hope to hear from this soon. Thanks

Translate

Forum|alt.badge.img

Did you get to use this method? i want to know if this works?

Translate

Forum|alt.badge.img

It's working! Sometimes getting error codes through. Figuring out why.

Translate

Forum|alt.badge.img

What type of account do you have? Personal or enterprise? Governance package?

Translate

Forum|alt.badge.img

Came across this thread recently with similar requirement.

Were you able to fix the issue you mentioned? And have you shared this code anywhere?

Thanks

Translate

Forum|alt.badge.img

Yes, I did finally get it working. I haven't posted the code anywhere, though. I have a .jar executable if one is interested. 

Translate

Forum|alt.badge.img

I would be interested in checking out this tool! Currently I have zapier sharing files that get added to a folder, but would be nice to do this as a batch without using my zapier tasks.

Translate

Forum|alt.badge.img

If I have 1000 files in the folder, will this code produce 1000 separate requests? If yes, is there any way I can make a bulk update?

Translate

Forum|alt.badge.img

Hi . Just encountering your message in this thread nearly a year after you posted, as I'm looking to solve the same kind of problem. I for one would love to get a look at your solution.

 

Seems like there are quite a few digital archivists using box.com for their file storage, who'd love a way to create spreadsheets of share links to that back-end content, for use with content-managed websites in searchable/sortable/filterable ways. Without an automated way to create those links, all of us need to use the ordinary box.com file interface and create every link by hand, then paste it into a spreadsheet row and add metadata columns, before being able to use that spreadsheet as the engine within a content-managed front end such as a WordPress site with a forms manager plugin.

 

I'm guessing that the sort of tool you describe having created, would be a great addition to the codepen examples at https://codepen.io/box-platform/pens/popular/?grid_type=list. Thanks for making the community aware of your work!

 

Jim

Translate

Forum|alt.badge.img

Hi Jim, whats the best way to get you the source code (java)?

Translate

Forum|alt.badge.img

Hi  . I've just sent you my email address in a private message. Thanks!!

Translate

Forum|alt.badge.img

This is awesome. Exactly what I am looking for. Can the code be downloaded somewhere?

 

Thanks!

Translate

Forum|alt.badge.img

Send me a private message and I'll email  it.

Translate