(albumName)
| 151 | |
| 152 | // snippet-start:[s3.JavaScript.photoAlbumExample.addPhoto] |
| 153 | function addPhoto(albumName) { |
| 154 | var files = document.getElementById("photoupload").files; |
| 155 | if (!files.length) { |
| 156 | return alert("Please choose a file to upload first."); |
| 157 | } |
| 158 | var file = files[0]; |
| 159 | var fileName = file.name; |
| 160 | var albumPhotosKey = encodeURIComponent(albumName) + "/"; |
| 161 | |
| 162 | var photoKey = albumPhotosKey + fileName; |
| 163 | |
| 164 | // Use S3 ManagedUpload class as it supports multipart uploads |
| 165 | var upload = new AWS.S3.ManagedUpload({ |
| 166 | params: { |
| 167 | Bucket: albumBucketName, |
| 168 | Key: photoKey, |
| 169 | Body: file, |
| 170 | }, |
| 171 | }); |
| 172 | |
| 173 | var promise = upload.promise(); |
| 174 | |
| 175 | promise.then( |
| 176 | function (data) { |
| 177 | alert("Successfully uploaded photo."); |
| 178 | viewAlbum(albumName); |
| 179 | }, |
| 180 | function (err) { |
| 181 | return alert("There was an error uploading your photo: ", err.message); |
| 182 | } |
| 183 | ); |
| 184 | } |
| 185 | // snippet-end:[s3.JavaScript.photoAlbumExample.addPhoto] |
| 186 | |
| 187 | // snippet-start:[s3.JavaScript.photoAlbumExample.deletePhoto] |
nothing calls this directly
no test coverage detected