Google Photos API - how can I set the order of the mediaItems within album?

Viewed 33

I'm using Tanaike-san's project here: https://github.com/tanaikech/GPhotoApp to add mediaItems to my shared album. I've updated the _apiCall code to specify a position:

      path: "mediaItems:batchCreate",
      payload: {
        albumId: opts.albumId,
        newMediaItems: newMediaItems,
        albumPosition: {                   <--- I added this
          position: "FIRST_IN_ALBUM"        <--- I added this
        }                                  <--- I added this
      }
    });

Using the following references: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate https://developers.google.com/photos/library/reference/rest/v1/AlbumPosition

..and that appeared to work perfectly for ~ 250 photos & videos.

Then, for some reason the mediaItems started appearing at the "bottom" of the album (LAST_IN_ALBUM).

I'm at a loss to explain why the uploads suddenly started appearing at the opposite end of the album, nor can I seem to fix it.

I tried changing "FIRST_IN_ALBUM" to "LAST_IN_ALBUM" and the new uploads continue to appear at the bottom ...making it look like there was no change.

Are albums actually made up of multiple groups of mediaItems? If so, then perhaps the new mediaItems are being added to the "FIRST" in that new group-list, and it happens to appear at the bottom of the existing album list-set???

I appreciate any insight into what's going on and ideas for how I can resolve this issue.

My goal is to just upload mediaItems and have them added to the "front" or "top" of my album, since I'm stepping through the items in date-order.

1 Answers

I finally figured out what happened.

A few days ago, I simply created a new album - and started uploading photos using my slightly modified version of @Tanaike-san's code.

Everything worked perfectly..all images were being added FIRST_IN_ALBUM.

Then, before all objects were added, I changed the album to a **shared album**!. Immediately after "creating a link" to share the album, all uploads using the same code, only added as LAST_IN_ALBUM.

By changing the album BACK to "private" (by turning OFF the "link sharing" slider)... now the objects begin adding FIRST_IN_ALBUM.

My experience indicates that mediaItems cannot be added FIRST_IN_ALBUM if they're being added to an album with "link sharing" enabled. Seems to me like a Google Photos bug or perhaps an undocumented feature!

Related