aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-11-27 04:25:55 -0500
committerSam Wilkins <samwilkins333@gmail.com>2019-11-27 04:25:55 -0500
commitdb6d3f77b1b429c1942019b79c44e378eb8b1ee4 (patch)
tree6730e54a0f31437699e807d753a8d1f0b2556c98
parentdf5584ccd40bd83f1362b32db67969e7ffbf2e3f (diff)
fixed google photos upload by appending size suffix
-rw-r--r--src/client/util/Import & Export/DirectoryImportBox.tsx10
-rw-r--r--src/server/ApiManagers/GooglePhotosManager.ts4
-rw-r--r--src/server/DashUploadUtils.ts14
3 files changed, 13 insertions, 15 deletions
diff --git a/src/client/util/Import & Export/DirectoryImportBox.tsx b/src/client/util/Import & Export/DirectoryImportBox.tsx
index 16ae50685..b5e806a97 100644
--- a/src/client/util/Import & Export/DirectoryImportBox.tsx
+++ b/src/client/util/Import & Export/DirectoryImportBox.tsx
@@ -119,17 +119,15 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
runInAction(() => this.completed += batch.length);
});
- const size = "_o";
- await Promise.all(uploads.map(async upload => {
- const type = upload.type;
- const path = Utils.prepend(upload.clientAccessPath);
+ await Promise.all(uploads.map(async ({ name, type, clientAccessPath, exifData }) => {
+ const path = Utils.prepend(clientAccessPath);
const options = {
nativeWidth: 300,
width: 300,
- title: upload.name
+ title: name
};
const document = await Docs.Get.DocumentFromType(type, path, options);
- const { data, error } = upload.exifData;
+ const { data, error } = exifData;
if (document) {
Doc.GetProto(document).exif = error || Docs.Get.DocumentHierarchyFromJson(data);
docs.push(document);
diff --git a/src/server/ApiManagers/GooglePhotosManager.ts b/src/server/ApiManagers/GooglePhotosManager.ts
index 5a709688b..4a0c0b936 100644
--- a/src/server/ApiManagers/GooglePhotosManager.ts
+++ b/src/server/ApiManagers/GooglePhotosManager.ts
@@ -5,7 +5,7 @@ import { GoogleApiServerUtils } from "../apis/google/GoogleApiServerUtils";
import { BatchedArray, TimeUnit } from "array-batcher";
import { GooglePhotosUploadUtils } from "../apis/google/GooglePhotosUploadUtils";
import { Opt } from "../../new_fields/Doc";
-import { DashUploadUtils } from "../DashUploadUtils";
+import { DashUploadUtils, InjectSize, SizeSuffix } from "../DashUploadUtils";
import { Database } from "../database";
const authenticationError = "Unable to authenticate Google credentials before uploading to Google Photos!";
@@ -55,7 +55,7 @@ export default class GooglePhotosManager extends ApiManager {
for (let index = 0; index < batch.length; index++) {
const { url, description } = batch[index];
const fail = (reason: string) => failed.push({ reason, batch: completedBatches + 1, index, url });
- const uploadToken = await GooglePhotosUploadUtils.DispatchGooglePhotosUpload(token, url).catch(fail);
+ const uploadToken = await GooglePhotosUploadUtils.DispatchGooglePhotosUpload(token, InjectSize(url, SizeSuffix.Original)).catch(fail);
if (!uploadToken) {
fail(`${path.extname(url)} is not an accepted extension`);
} else {
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 0a670ec01..81cd2d602 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -21,12 +21,12 @@ export enum SizeSuffix {
Original = "_o"
}
-export namespace DashUploadUtils {
+export function InjectSize(filename: string, size: SizeSuffix) {
+ const extension = path.extname(filename).toLowerCase();
+ return filename.substring(0, filename.length - extension.length) + size + extension;
+}
- function InjectSize(filename: string, size: SizeSuffix) {
- const extension = path.extname(filename).toLowerCase();
- return filename.substring(0, filename.length - extension.length) + size + extension;
- }
+export namespace DashUploadUtils {
export interface Size {
width: number;
@@ -72,8 +72,8 @@ export namespace DashUploadUtils {
switch (category) {
case "image":
if (imageFormats.includes(format)) {
- const { clientAccessPath } = await UploadImage(path, basename(path), format);
- return { clientAccessPath, name, type };
+ const results = await UploadImage(path, basename(path), format);
+ return { ...results, name, type };
}
case "video":
if (videoFormats.includes(format)) {