in Education by
I am trying to consume this API for dart using Flutter: https://pixcut.wondershare.com/api.html. My images are saved in the database as strings, and I am using methods to convert to string, Uint8list or Image as you can see below. I am trying to use http.MultipartRequest to get the image without background, but I get this error: [log] {"Code":10001,"Msg":"fail msg : http: no such file","Data":null} void removeBackground(String image) async { var request = http.MultipartRequest( "POST", Uri.parse('https://pixcut.wondershare.com/openapi/api/v1/matting/removebg')); request.headers.addAll( { r'Content-Type': 'multipart/form-data', r'appkey': '061c4600615d101a56330357cafce7d9', }, ); request.files .add(http.MultipartFile.fromBytes('content', CleverCloset.dataFromBase64String(image) // use the real name if available, or omit )); await request.send().then((response) { http.Response.fromStream(response).then((onValue) { try { log(onValue.body); //stackChildren.add(MoveableStackItem(CleverCloset.imageFromBase64String(onValue.body).image)); log("bb"); setState(() { }); // get your response here... } catch (e) { log(e.toString()); log("ddd"); // handle exeption } }); }); } static Uint8List dataFromBase64String(String base64String) { return base64Decode(base64String); } static String base64String(Uint8List data) { return base64Encode(data); } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
import package dio https://pub.dev/packages/dio And replace those codes with your own code Future uploadImage(File file) async { var dio = Dio(); var url = "https://pixcut.wondershare.com/openapi/api/v1/matting/removebg"; String fileName = file.path.split('/').last; FormData formData = FormData.fromMap({ "content": await MultipartFile.fromFile(file.path, filename:fileName), }); var response = await dio.post(url, data: formData, options: Options(contentType: "multipart/form-data", headers: {"appkey":"061c4600615d101a56330357cafce7d9"})); print(response.statusCode); return response.data; }

Related questions

0 votes
    This is my code it's just starting the scan but it is not completing ,where is the error in it. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I am trying to implement the Hateoas using spring boot. In my UserController class i have used the below ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I am a beginner and I just need a bit of help on why I getline is showing an error: this is what I have so far ... payments[MAX_ITEMS]; ifstream iFile; if ( argc != 2 ) { cout...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I am a beginner and I just need a bit of help on why I getline is showing an error: this is what I have so far ... payments[MAX_ITEMS]; ifstream iFile; if ( argc != 2 ) { cout...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    Trying to implement OCR in the bank environment but the challenge is, we don't have access to an internet connection ... in our bank. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    If I have a view in SQL which contains various computed columns, some of which could be very expensive, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I have the following data frame: df = data.frame(date = "23-12-09 22:52") This code works fine ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I'm trying to fetch some data from the REST API of HP Alm. It works pretty well with a small ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    i'm trying to test with jest this route on my node microservice. At the initalisation of my microservice ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I've been putzing with trying to call the jobs.Insert bigquery rest api endpoint with node (the jobs. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
...