PRO-INDIA / pro_resumable_upload

Open source flutter package for resumable file upload
MIT License
4 stars 4 forks source link

ResumableUploadException: Upload Failed #5

Open sauravcodexlancers opened 5 months ago

sauravcodexlancers commented 5 months ago
uploadImageUsingResumableUpload()async{

    // Url Example 
    // https://[Account-Name].blob.core.windows.net/public/[container-name]/2024-05-08_14%3A15%3A40.198221.png?sv=2023-11-03&se=2024-05-08T09%3A45%3A45Z&sr=b&sp=rw&sig=QuH7u6%2FbbmfmTULeJkVaDwHYIaxDr%2FznVjddnKuI3UY%3D

    // Get SAS token
    await getUploadTokenAPi();

    // SAS token utils
    String sas = uploadtokenResponce.data["token"]??"";
    String storageAccountUrl = sas.substring(0, getSubstringIndex(sas, 3));
    String sasToken = sas.split("?").last;

    // Generate image file
    final image = await _signaturePadKey.currentState!.toImage();
    final byteData = await image.toByteData(format: ui.ImageByteFormat.png);

    final path = await getApplicationDocumentsDirectory();
    String filePath = path.path+"${sas.split("?").first.split("/").last}";
    File imageFile = await File(filePath);
    await imageFile.create(recursive: true);
    await imageFile.writeAsBytes(byteData?.buffer.asUint8List()??[]);

    // Create Client
    UploadClient client = UploadClient(
        file: imageFile, // Default 4MB
        timeout: const Duration(seconds: 50), // Default 30sec
        blobConfig: BlobConfig(
          sasToken: sasToken, blobUrl: storageAccountUrl,
        ),
    );

    // Start Uploading
    await client.uploadBlob(
      onComplete: (value,response){

      },
    );
  }

Error

<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:6422903a-101e-0051-4027-a17feb000000
Time:2024-05-08T09:07:31.9196525Z</Message><AuthenticationErrorDetail>The specified signed resource is not allowed for the this resource level</AuthenticationErrorDetail></Error>

Description I'm try to upload image blob using API request. While testing the functionality via Postman, we've observed that the image upload process is successful, yielding a status code of 201. However, when attempting the same operation from within our application, although we receive a status code of 201, the image fails to load.

YesThatGy commented 2 months ago

We are having similar results, except that the upload isn't successful, either.

For the TUS server we are using ankitpokhrel/tus-php on AlmaLinux 9 host with PHP 8.3.9. Using the reference TUS client uppy we can upload without issue. https://uppy.io/docs/tus/

For the devs (Pro-India) I'd be happy to share my test server address.

ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ResumableUploadException: Upload Failed