MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / createAlbum

Function createAlbum

javascript/example_code/s3/s3_photoExample.js:67–91  ·  view source on GitHub ↗
(albumName)

Source from the content-addressed store, hash-verified

65
66// snippet-start:[s3.JavaScript.photoAlbumExample.createAlbum]
67function createAlbum(albumName) {
68 albumName = albumName.trim();
69 if (!albumName) {
70 return alert("Album names must contain at least one non-space character.");
71 }
72 if (albumName.indexOf("/") !== -1) {
73 return alert("Album names cannot contain slashes.");
74 }
75 var albumKey = encodeURIComponent(albumName);
76 s3.headObject({ Key: albumKey }, function (err, data) {
77 if (!err) {
78 return alert("Album already exists.");
79 }
80 if (err.code !== "NotFound") {
81 return alert("There was an error creating your album: " + err.message);
82 }
83 s3.putObject({ Key: albumKey }, function (err, data) {
84 if (err) {
85 return alert("There was an error creating your album: " + err.message);
86 }
87 alert("Successfully created album.");
88 viewAlbum(albumName);
89 });
90 });
91}
92// snippet-end:[s3.JavaScript.photoAlbumExample.createAlbum]
93
94// snippet-start:[s3.JavaScript.photoAlbumExample.viewAlbum]

Callers

nothing calls this directly

Calls 2

viewAlbumFunction · 0.70
putObjectMethod · 0.45

Tested by

no test coverage detected