[Awmp] Rust awmp persist_in() problem

I am a newbie and I am trying to change the temp_directory with awmp::PathConfig::with_temp_dir() inside a newly created actix app as an argument to .app_data(web::Data::new(-------)).

It gives me an error saying "expected value, found struct".

what could be the official way to change the temp location with awmp, so that the persist_in() function can work?

Can you paste the full error message you get when running cargo build? There's a good chance this is just a syntax error and the compiler's error message also included a suggestion that you could try.

...
async fn add_cat_form(
        pool: web::Data<DbPool>,
        mut parts: Parts,
    )-> Result<HttpResponse, Error>{
        let file_path = parts
            .files
            .take("image")
            .pop()
            .and_then(|f| f.persist_in("./static/image").ok())
            .unwrap_or_default();
......}

#[actix_web::main]
async fn main()-> std::io::Result<()>{
...
HttpServer::new(move|| {
          App::new()
               .app_data(handlebars_ref.clone())
               .app_data(web::Data::new(pool.clone()))
               .service(
                   Files::new("/static", "static")
                       .show_files_listing(),
               )
               .route("/", web::get().to(index))
               .route("/add", web::get().to(add))
               .route("/add_cat_form", web::post().to(add_cat_form))
      }) ...
...}

this is the code, here when i use the persist_in() function with std::env::temp_dir(), works well. But any other directory, it dosent read/write at all. There is no compiler error for this.Is there any way to change the directories other than std::env::temp_dir().

...
App::new()
.app_data(awmp::PartsConfig::default().with_temp_dir("./static/image"))
...
this was the syntax i was searching for and now the temp directory can be changed.
thankyou Michael-F-Bryan.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.