Skip to content

Commit e634bf5

Browse files
committed
feat(core_sdk): remove reading file and replace with upload url
1 parent 0708bab commit e634bf5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

typegraph/core/src/utils/postprocess/wasmedge_rt.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
// SPDX-License-Identifier: MPL-2.0
33

44
use crate::utils::fs_host;
5-
use crate::wit::metatype::typegraph::host::read_file;
6-
use common::{
7-
archive::encode_bytes_to_base_64,
8-
typegraph::{
9-
runtimes::wasmedge::WasiMatData,
10-
utils::{map_from_object, object_from_map},
11-
Typegraph,
12-
},
5+
use common::typegraph::{
6+
runtimes::wasmedge::WasiMatData,
7+
utils::{map_from_object, object_from_map},
8+
Typegraph,
139
};
1410
use std::path::PathBuf;
1511

@@ -19,6 +15,7 @@ pub struct WasmedgeProcessor;
1915

2016
impl PostProcessor for WasmedgeProcessor {
2117
fn postprocess(self, tg: &mut Typegraph) -> Result<(), crate::errors::TgError> {
18+
let tg_name = tg.name().unwrap();
2219
for mat in tg.materializers.iter_mut() {
2320
if mat.name.as_str() == "wasi" {
2421
let mut mat_data: WasiMatData =
@@ -28,8 +25,14 @@ impl PostProcessor for WasmedgeProcessor {
2825
};
2926

3027
let wasi_path = fs_host::make_absolute(&PathBuf::from(path))?;
31-
let bytes = read_file(&wasi_path.display().to_string())?;
32-
mat_data.wasm = encode_bytes_to_base_64(bytes).map_err(|e| e.to_string())?;
28+
let file_name = path.split('/').last().unwrap();
29+
let artifact_hash = mat_data.artifact_hash.clone();
30+
let wasm_path = format!(
31+
"tmp/metatype-artifacts/{}/files/{}.{}",
32+
tg_name, file_name, artifact_hash
33+
);
34+
35+
mat_data.wasm = wasm_path;
3336

3437
mat.data = map_from_object(mat_data).map_err(|e| e.to_string())?;
3538
tg.deps.push(wasi_path);

0 commit comments

Comments
 (0)