mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Move Binary Data Node): Stringify objects before encoding them in MoveBinaryData (#4882)
* stringify objects before encoding them objects in MoveBinaryData * add fileSize and fileType on MoveBinaryData converted data * show `view` option for text files as well * improve how JSON binary data is shown in the UI
This commit is contained in:
committed by
GitHub
parent
f4481e24e8
commit
3b969d2cd1
@@ -11,6 +11,12 @@
|
||||
<source :src="embedSource" :type="binaryData.mimeType">
|
||||
{{ $locale.baseText('binaryDataDisplay.yourBrowserDoesNotSupport') }}
|
||||
</video>
|
||||
<vue-json-pretty
|
||||
v-else-if="binaryData.fileType === 'json'"
|
||||
:data="jsonData"
|
||||
:deep="3"
|
||||
:showLength="true"
|
||||
/>
|
||||
<embed v-else :src="embedSource" class="binary-data" :class="embedClass()"/>
|
||||
</span>
|
||||
</span>
|
||||
@@ -19,38 +25,56 @@
|
||||
<script lang="ts">
|
||||
import mixins from 'vue-typed-mixins';
|
||||
import { restApi } from '@/mixins/restApi';
|
||||
import type { IBinaryData } from 'n8n-workflow';
|
||||
import { IBinaryData, jsonParse } from 'n8n-workflow';
|
||||
import type { PropType } from 'vue';
|
||||
import VueJsonPretty from 'vue-json-pretty';
|
||||
|
||||
export default mixins(
|
||||
restApi,
|
||||
)
|
||||
.extend({
|
||||
name: 'BinaryDataDisplayEmbed',
|
||||
props: [
|
||||
'binaryData', // IBinaryData
|
||||
],
|
||||
components: {
|
||||
VueJsonPretty,
|
||||
},
|
||||
props: {
|
||||
binaryData: {
|
||||
type: Object as PropType<IBinaryData>,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isLoading: true,
|
||||
embedSource: '',
|
||||
error: false,
|
||||
jsonData: '',
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
const id = this.binaryData?.id;
|
||||
const isJSONData = this.binaryData.fileType === 'json';
|
||||
|
||||
if(!id) {
|
||||
this.embedSource = 'data:' + this.binaryData.mimeType + ';base64,' + this.binaryData.data;
|
||||
this.isLoading = false;
|
||||
return;
|
||||
if (isJSONData) {
|
||||
this.jsonData = jsonParse(atob(this.binaryData.data));
|
||||
} else {
|
||||
this.embedSource = 'data:' + this.binaryData.mimeType + ';base64,' + this.binaryData.data;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const binaryUrl = this.restApi().getBinaryUrl(id);
|
||||
if (isJSONData) {
|
||||
this.jsonData = await (await fetch(binaryUrl)).json();
|
||||
} else {
|
||||
this.embedSource = binaryUrl;
|
||||
}
|
||||
} catch (e) {
|
||||
this.error = true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this.embedSource = this.restApi().getBinaryUrl(id);
|
||||
this.isLoading = false;
|
||||
} catch (e) {
|
||||
this.isLoading = false;
|
||||
this.error = true;
|
||||
}
|
||||
this.isLoading = false;
|
||||
},
|
||||
methods: {
|
||||
embedClass(): string[] {
|
||||
|
||||
Reference in New Issue
Block a user