diff --git a/Dotnet/WebApi.cs b/Dotnet/WebApi.cs index c8ca3f96..eb841071 100644 --- a/Dotnet/WebApi.cs +++ b/Dotnet/WebApi.cs @@ -304,9 +304,8 @@ namespace VRCX var boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x"); request.ContentType = "multipart/form-data; boundary=" + boundary; var requestStream = request.GetRequestStream(); - // var requestStream = new MemoryStream(); var imageData = options["imageData"] as string; - var fileToUpload = Convert.FromBase64String(imageData); + var fileToUpload = AppApi.Instance.ResizeImageToFitLimits(Convert.FromBase64String(imageData), 1920, 1080); const string fileFormKey = "image"; const string fileName = "image"; const string fileMimeType = "image/png"; @@ -315,6 +314,8 @@ namespace VRCX var header = string.Format(headerTemplate, boundary, fileFormKey, fileName, fileMimeType, fileSize); var headerBytes = Encoding.UTF8.GetBytes(header); await requestStream.WriteAsync(headerBytes); + var newlineBytes = Encoding.UTF8.GetBytes("\r\n"); + await requestStream.WriteAsync(newlineBytes); using (var fileStream = new MemoryStream(fileToUpload)) { var buffer = new byte[1024]; @@ -325,10 +326,9 @@ namespace VRCX } fileStream.Close(); } - var newlineBytes = Encoding.UTF8.GetBytes("\r\n"); - await requestStream.WriteAsync(newlineBytes); const string textContentType = "text/plain; charset=utf-8"; - const string formDataTemplate = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\nContent-Type: {2}\r\nContent-Length: {3}\r\n{4}\r\n"; + const string formDataTemplate = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\nContent-Type: {2}\r\nContent-Length: {3}\r\n\r\n{4}\r\n"; + await requestStream.WriteAsync(newlineBytes); if (options.TryGetValue("postData", out var postDataObject)) { var jsonPostData = JsonConvert.DeserializeObject>(postDataObject.ToString()); @@ -344,13 +344,7 @@ namespace VRCX } var endBytes = Encoding.UTF8.GetBytes("--" + boundary + "--"); await requestStream.WriteAsync(endBytes); - // test file - // var newFileStream = new FileStream(@"D:\WindowsFiles\Desktop\test", FileMode.Create, FileAccess.Write); - // requestStream.WriteTo(newFileStream); - // newFileStream.Close(); - requestStream.Close(); - // throw new NotImplementedException(); } #pragma warning disable CS4014 diff --git a/html/src/app.js b/html/src/app.js index 326117ab..7bff114b 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -17505,7 +17505,7 @@ speechSynthesis.getVoices(); }; API.$on('PRINT:LIST', function (args) { - $app.printTable = args.json.reverse(); + $app.printTable = args.json; $app.galleryDialogPrintsLoading = false; }); @@ -17524,6 +17524,8 @@ speechSynthesis.getVoices(); } }); + $app.data.printUploadNote = ''; + $app.methods.onFileChangePrint = function (e) { var clearFile = function () { if (document.querySelector('#PrintUploadButton')) { @@ -17556,8 +17558,8 @@ speechSynthesis.getVoices(); var date = new Date(); var timestamp = date.toISOString().slice(0, 19); var params = { - note: 'test print', - worldId: 'wrld_10e5e467-fc65-42ed-8957-f02cace1398c', + note: $app.printUploadNote, + // worldId: '', timestamp }; var base64Body = btoa(r.result); diff --git a/html/src/localization/en/en.json b/html/src/localization/en/en.json index 8deabfe9..5c139701 100644 --- a/html/src/localization/en/en.json +++ b/html/src/localization/en/en.json @@ -1270,7 +1270,7 @@ }, "gallery_icons": { "header": "Manage Photos, Icons, Emojis and Stickers", - "description": "Recommended image size: 1200x900px (4:3)", + "recommended_image_size": "Recommended image size", "gallery": "Photos", "icons": "Icons", "emojis": "Emojis", @@ -1284,7 +1284,8 @@ "emoji_animation_fps": "FPS:", "emoji_animation_frame_count": "Frame Count:", "emoji_loop_pingpong": "Loop PingPong", - "flipbook_info": "Select a 1024x1024 PNG spritesheet to use as an animated emoji, available frame grid sizes: 4, 16 or 64 (max FPS 64, max frames 64)" + "flipbook_info": "Select a 1024x1024 PNG spritesheet to use as an animated emoji, available frame grid sizes: 4, 16 or 64 (max FPS 64, max frames 64)", + "note": "Note" }, "change_content_image": { "avatar": "Change Avatar Image", diff --git a/html/src/mixins/dialogs/currentUser.pug b/html/src/mixins/dialogs/currentUser.pug index c1a74293..2f90e2db 100644 --- a/html/src/mixins/dialogs/currentUser.pug +++ b/html/src/mixins/dialogs/currentUser.pug @@ -61,14 +61,14 @@ mixin currentUser() //- dialog: Gallery/VRCPlusIcons el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="galleryDialog" :visible.sync="galleryDialogVisible" :title="$t('dialog.gallery_icons.header')" width="100%") - span(style="padding-bottom:10px") {{ $t('dialog.gallery_icons.description') }} - br - br el-tabs(type="card" ref="galleryTabs") el-tab-pane(v-if="galleryDialogVisible" v-loading="galleryDialogGalleryLoading") span(slot="label") {{ $t('dialog.gallery_icons.gallery') }} span(style="color:#909399;font-size:12px;margin-left:5px") {{ galleryTable.length }}/64 input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangeGallery" id="GalleryUploadButton" style="display:none") + span {{ $t('dialog.gallery_icons.recommended_image_size') }}: 1200x900px (4:3) + br + br el-button-group el-button(type="default" size="small" @click="refreshGalleryTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }} el-button(type="default" size="small" @click="displayGalleryUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} @@ -84,6 +84,9 @@ mixin currentUser() span(slot="label") {{ $t('dialog.gallery_icons.icons') }} span(style="color:#909399;font-size:12px;margin-left:5px") {{ VRCPlusIconsTable.length }}/64 input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangeVRCPlusIcon" id="VRCPlusIconUploadButton" style="display:none") + span {{ $t('dialog.gallery_icons.recommended_image_size') }}: 1200x900px (4:3) + br + br el-button-group el-button(type="default" size="small" @click="refreshVRCPlusIconsTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }} el-button(type="default" size="small" @click="displayVRCPlusIconUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} @@ -99,6 +102,9 @@ mixin currentUser() span(slot="label") {{ $t('dialog.gallery_icons.emojis') }} span(style="color:#909399;font-size:12px;margin-left:5px") {{ emojiTable.length }}/9 input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangeEmoji" id="EmojiUploadButton" style="display:none") + span {{ $t('dialog.gallery_icons.recommended_image_size') }}: 1200x900px (4:3) + br + br el-button-group(style="margin-right:10px") el-button(type="default" size="small" @click="refreshEmojiTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }} el-button(type="default" size="small" @click="displayEmojiUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} @@ -140,6 +146,9 @@ mixin currentUser() span(slot="label") {{ $t('dialog.gallery_icons.stickers') }} span(style="color:#909399;font-size:12px;margin-left:5px") {{ stickerTable.length }}/9 input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangeSticker" id="StickerUploadButton" style="display:none") + span {{ $t('dialog.gallery_icons.recommended_image_size') }}: 1200x900px (4:3) + br + br el-button-group el-button(type="default" size="small" @click="refreshStickerTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }} el-button(type="default" size="small" @click="displayStickerUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} @@ -154,9 +163,13 @@ mixin currentUser() span(slot="label") {{ $t('dialog.gallery_icons.prints') }} span(style="color:#909399;font-size:12px;margin-left:5px") {{ printTable.length }}/64 input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangePrint" id="PrintUploadButton" style="display:none") + span {{ $t('dialog.gallery_icons.recommended_image_size') }}: 1920x1080px (16:9) + br + br el-button-group el-button(type="default" size="small" @click="refreshPrintTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }} - //- el-button(type="default" size="small" @click="displayPrintUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} + el-button(type="default" size="small" @click="displayPrintUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} + el-input(type="textarea" v-model="printUploadNote" size="mini" rows="1" resize="none" maxlength="32" style="margin-left:10px;width:300px" :placeholder="$t('dialog.gallery_icons.note')") br .x-friend-item(v-for="image in printTable" :key="image.id" style="display:inline-block;margin-top:10px;width:unset;cursor:default") .vrcplus-icon(style="overflow:hidden" @click="showFullscreenImageDialog(image.files.image)") @@ -168,6 +181,8 @@ mixin currentUser() span(v-else style="display:block")   display-name.x-ellipsis(v-if="image.authorId" :userid="image.authorId" :hint="image.authorName" style="color:#909399;font-family:monospace;display:block") span(v-else style="font-family:monospace;display:block")   + span.x-ellipsis(v-if="image.timestamp" style="color:#909399;font-family:monospace;font-size:11px;display:block") {{ image.timestamp | formatDate('long') }} + span(v-else style="display:block")   div(style="float:right") el-button(type="default" @click="showFullscreenImageDialog(image.files.image)" size="mini" icon="el-icon-picture-outline" circle) el-button(type="default" @click="deletePrint(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")