Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I Can't send other format message? Please add this functionality. #36

Closed
Significantinfotech2020 opened this issue Oct 19, 2020 · 51 comments

Comments

@Significantinfotech2020

ConnectyCube Support Team,

I can't send video, audio, gif format while I use for chatting functionality with connectycube_sdk in flutter. So, please add this functionality in your sdk. If you already done this functionality, then suggest me, how to accomplish this functionality with connectycube_sdk.

@Significantinfotech2020 Significantinfotech2020 changed the title Can't send other format message? Please add this functionality. I Can't send other format message? Please add this functionality. Oct 19, 2020
@TatankaConCube
Copy link
Contributor

hello @Significantinfotech2020, you can send any data in the message's attachment. Our Flutter SDK doesn't have limits in this part. The main logic will be the same as sending images. Just set type for your attachment via attachment.type = CubeAttachmentType.AUDIO_TYPE; and add own widget for displaying this type of attachments.

@Significantinfotech2020
Copy link
Author

Significantinfotech2020 commented Oct 20, 2020

hello @Significantinfotech2020, you can send any data in the message's attachment. Our Flutter SDK doesn't have limits in this part. The main logic will be the same as sending images. Just set type for your attachment via attachment.type = CubeAttachmentType.AUDIO_TYPE; and add own widget for displaying this type of attachments.

I tried with this line of code but I can't send video and other formatted files. Also I tried with this link but didn't get any solution. https://developers.connectycube.com/flutter/messaging?id=attachments .

Issue is when I select video file It upload on dashboard chat history but in the app, on dialog page it displays this is not an Image type. and display error image.

@TatankaConCube
Copy link
Contributor

As I said before:

and add own widget for displaying this type of attachments.

It means you have to realize this functionality by yourself.
Our samplec created for demonstration of how to use ConnectyCube Flutter SDK, how to integrate it into your projects, how to login to the REST and to the chat, how to send and to listen messages, how to make calls, etc. It is not ready to use a chat application.

@Significantinfotech2020
Copy link
Author

Hello @TatankaConCube

For delete selected message I use delete() method as per documentation.

List<String> ids = ["5e394e7bca8bf410bc8017b0", "5e394e7bca8bf466137fa1eb"];
bool force = false; // true - to delete everywhere, false - to delete for himself

deleteMessages(ids, force)
    .then((deleteItemsResult) {})
    .catchError((error) {});

But in this method which Ids use in the List<String> ids = ["5e394e7bca8bf410bc8017b0", "5e394e7bca8bf466137fa1eb"];

I use in this List<String> ids = [_cubeDialog.id.toString(), _cubeDialog.dialogId];

but I got this error when I press delete button:

DELETE ERROR ==> ResponseException: 404: {"errors":["The resource wasn't found"]}

So, suggest me. How can I do this functionality?

@TatankaConCube
Copy link
Contributor

List ids = ["5e394e7bca8bf410bc8017b0", "5e394e7bca8bf466137fa1eb"];

in our example, there are ids of messages, which you want to delete. But in your example, you use the id of dialog but not the id of the message. It is an expected error because the server can't found messages with these ids.

@Significantinfotech2020
Copy link
Author

List ids = ["5e394e7bca8bf410bc8017b0", "5e394e7bca8bf466137fa1eb"];

in our example, there are ids of messages, which you want to delete. But in your example, you use the id of dialog but not the id of the message. It is an expected error because the server can't found messages with these ids.

@TatankaConCube

I got message_id null. How to get get it ?

I tried to get message_id this way, If any other way to get message_Id then suggest me.

CubeMessage _message;
List ids = [_message.messageId];

@TatankaConCube
Copy link
Contributor

where did you get this message? For messages loaded from the server, this field can not be null.

@Significantinfotech2020
Copy link
Author

where did you get this message?

I use this method on delete icon onClick.

void deleteMessage() {
    var message = CubeMessage();
    print('MESSAGEID => ${message.messageId}');
    List<String> ids = [message.messageId ];
    bool force =
        false; // true - to delete everywhere, false - to delete for himself

    deleteMessages(ids, force)
        .then((deleteItemsResult) {
          print('DELETEMESSAGESUCCESS ==> $deleteItemsResult');
    })
        .catchError((error) {
          print('DELETEMESSAGEERROR ==> $error');
    });
  }

Using this method I got this error log.
{"errors":["The resource wasn't found"]}

@TatankaConCube
Copy link
Contributor

It is because you didn't upload the message to the server. In your example, you just created a local object and the server doesn't know anything about it. For the creation message on server, you have to send a message via chat or create it via REST request.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

For transferring video in chat attachment, what should I have to do in chat dialog screen?

I used this snippet to transfer video file.

Future uploadVideo() {
    uploadFile(file).then((cubeFile) {
      CubeMessage message = CubeMessage();
      var url = cubeFile.getPrivateUrl();
      print('URl video = ${cubeFile.getPrivateUrl()}');
      message.body = 'Attachment';
      message.saveToHistory = true;
      message.markable = true;

      CubeAttachment attachment = CubeAttachment();
      attachment.uid = cubeFile.uid;
      attachment.type = CubeAttachmentType.VIDEO_TYPE;
      attachment.url = url;
      message.attachments = [attachment];

      return onSendMessage(message);
    }).catchError((error) {});
  }

but I did not see video file same as image file in chat screen. In dashboard the video URL is uploaded, but when I post this url in browser, it does not play video. Here I post this uploaded video link.

So, please suggest me to share video in this chat application step by step.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

For transferring video in chat attachment, what should I have to do in chat dialog screen?

I used this snippet to transfer video file.

Future uploadVideo() {
    uploadFile(file).then((cubeFile) {
      CubeMessage message = CubeMessage();
      var url = cubeFile.getPrivateUrl();
      print('URl video = ${cubeFile.getPrivateUrl()}');
      message.body = 'Attachment';
      message.saveToHistory = true;
      message.markable = true;

      CubeAttachment attachment = CubeAttachment();
      attachment.uid = cubeFile.uid;
      attachment.type = CubeAttachmentType.VIDEO_TYPE;
      attachment.url = url;
      message.attachments = [attachment];

      return onSendMessage(message);
    }).catchError((error) {});
  }

but I did not see video file same as image file in chat screen. In dashboard the video URL is uploaded, but when I post this url in browser, it does not play video. Here I post this uploaded video link.

So, please suggest me to share video in this chat application step by step.

@TatankaConCube Please help me to solve my confusion.

@TatankaConCube
Copy link
Contributor

TatankaConCube commented Nov 12, 2020

you uploaded the file as private and you can get it only by private link, which contains token of the session. You can load this file by link from this code var url = cubeFile.getPrivateUrl();Did you try to get the file by this link?

@TatankaConCube
Copy link
Contributor

for getting a link on the opponent's side you should build it dynamically. Our SDK has the method getPrivateUrlForUid(String uid) for building a private URL from the uid of your file.

@Significantinfotech2020
Copy link
Author

you uploaded the file as private and you can get it only by private link, which contains token of the session. You can load this file by link from this code var url = cubeFile.getPrivateUrl();

I set url as private which is I mention in above code in upload file method. var url = cubeFile.getPrivateUrl();

Did you try to get the file by this link?

Yes, you can see my above code in which I uploaded url as private.

@TatankaConCube
Copy link
Contributor

which problem do you have now? can you get file by this URL var url = cubeFile.getPrivateUrl();?

@Significantinfotech2020
Copy link
Author

Significantinfotech2020 commented Nov 13, 2020

for getting a link on the opponent's side you should build it dynamically. Our SDK has the method getPrivateUrlForUid(String uid) for building a private URL from the uid of your file.

For getting file I use this way

final ChatMessagesManager chatMessagesManager = CubeChatConnection.instance.chatMessagesManager;

StreamSubscription<CubeMessage> msgSubscription;

 @override
  void initState() {
    super.initState();
    msgSubscription = chatMessagesManager.chatMessagesStream.listen(onReceiveMessage);
  }

void onReceiveMessage(CubeMessage message) {
    log("onReceiveMessage message= $message");
    if (message.dialogId != _cubeDialog.dialogId ||
        message.senderId == _cubeUser.id) return;
    String attachmentUid = message.attachments?.first?.uid;
    if (attachmentUid != null) {
      String attachmentUrl = getPrivateUrlForUid(attachmentUid);
      print('attachmentURl: ' + attachmentUrl);
    }
  }

In this method, I can't get print('attachmentURl: ' + attachmentUrl); this log in terminal.

So, please suggest me where I do mistake.

@Significantinfotech2020
Copy link
Author

which problem do you have now? can you get file by this URL var url = cubeFile.getPrivateUrl();?

Yes, I print this url in terminal. but problem is when I select this video link and paste it into chrome browser, then it link does not play video. and chat list I did not get video but I get image_not_found image as attachment.

@TatankaConCube
Copy link
Contributor

TatankaConCube commented Nov 13, 2020

can you share url to my e-mail val@connectycube.com or to support@connectycube.com?

@Significantinfotech2020
Copy link
Author

can you share url to my e-mail val@connectycube.com or to support@connectycube.com?

Yes, I share link. Please check it.

@TatankaConCube
Copy link
Contributor

did this file load successfully?

@Significantinfotech2020
Copy link
Author

did this file load successfully?

In chat page I can not load this file. but In that this widget

if (message.senderId == _cubeUser.id) {
      // Right (own message)
      return Column(
        children: <Widget>[
          isHeaderView() ? getHeaderDateWidget() : SizedBox.shrink(),
          Row(
            children: <Widget>[
              message.attachments?.isNotEmpty ?? false
                  // Image
                  ? Container(
                      child: FlatButton(
                        child: Material(
                          child: Column(
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                                CachedNetworkImage(
                                  placeholder: (context, url) => Container(
                                    child: CircularProgressIndicator(
                                      valueColor: AlwaysStoppedAnimation<Color>(
                                          themeColor),
                                    ),
                                    width: 200.0,
                                    height: 200.0,
                                    padding: EdgeInsets.all(70.0),
                                    decoration: BoxDecoration(
                                      color: greyColor2,
                                      borderRadius: BorderRadius.all(
                                        Radius.circular(8.0),
                                      ),
                                    ),
                                  ),
                                  errorWidget: (context, url, error) =>
                                      Material(
                                    child: Image.asset(
                                      'assets/images/splash.png',
                                      width: 200.0,
                                      height: 200.0,
                                      fit: BoxFit.cover,
                                    ),
                                    borderRadius: BorderRadius.all(
                                      Radius.circular(8.0),
                                    ),
                                    clipBehavior: Clip.hardEdge,
                                  ),
                                  imageUrl: message.attachments.first.url,
                                  width: 200.0,
                                  height: 200.0,
                                  fit: BoxFit.cover,
                                ),
                                getDateWidget(),
                                getReadDeliveredWidget(),
                              ]),
                          borderRadius: BorderRadius.all(Radius.circular(8.0)),
                          clipBehavior: Clip.hardEdge,
                        ),
                        onPressed: () {
                          Navigator.push(
                              context,
                              MaterialPageRoute(
                                  builder: (context) => FullPhoto(
                                      url: message.attachments.first.url)));
                        },
                        padding: EdgeInsets.all(0),
                      ),
                      margin: EdgeInsets.only(
                          bottom: isLastMessageRight(index) ? 20.0 : 10.0,
                          right: 10.0),
                    )
                  : message.body != null && message.body.isNotEmpty
                      // Text
                      ? Flexible(
                          child: Container(
                            padding:
                                EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
                            decoration: BoxDecoration(
                                color: greyColor2,
                                borderRadius: BorderRadius.circular(8.0)),
                            margin: EdgeInsets.only(
                                bottom: isLastMessageRight(index) ? 20.0 : 10.0,
                                right: 10.0),
                            child: Column(
                                crossAxisAlignment: CrossAxisAlignment.end,
                                children: [
                                  Text(
                                    message.body,
                                    style: TextStyle(color: primaryColor),
                                  ),
                                  getDateWidget(),
                                  getReadDeliveredWidget(),
                                ]),
                          ),
                        )
                      : Container(
                          child: Text(
                            "Empty",
                            style: TextStyle(color: primaryColor),
                          ),
                          padding: EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
                          width: 200.0,
                          decoration: BoxDecoration(
                              color: greyColor2,
                              borderRadius: BorderRadius.circular(8.0)),
                          margin: EdgeInsets.only(
                              bottom: isLastMessageRight(index) ? 20.0 : 10.0,
                              right: 10.0),
                        ),
            ],
            mainAxisAlignment: MainAxisAlignment.end,
          ),
        ],
      );
    } 

I mean display image which we set as this is not image.

@TatankaConCube
Copy link
Contributor

sorry, I meant the uploading process, it was successfully? which size of this file? did you try to upload the same file with public access?
Please provide the full log from your flutter console during the uploading the file.

@Significantinfotech2020
Copy link
Author

I meant the uploading process, it was successfully?

Yes, this url also I can see in dashboard.

which size of this file?

242 kb.

did you try to upload the same file with public access?

No, still I did not try with public access.

Please provide the full log from your flutter console during the uploading the file.

age=5; HttpOnly; secure, status: 201 Created, transfer-encoding: chunked, date: Fri, 13 Nov 2020 09:48:16 GMT, access-control-allow-origin: *, strict-transport-security: ma
x-age=31536000,max-age=15768000;, content-type: application/json; charset=utf-8, x-xss-protection: 1; mode=block, server: nginx/1.16.1, x-request-id: bf480286-c3cd-4a43-9b2
7-1dcbd4d9430e, cb-token-expirationdate: 2020-11-13 11:47:55 UTC, connectycube-rest-api-version: 0.1.1, x-runtime: 0.045153, etag: W/"6c41bfab3579238f951d9641f5c1097c", x-f
rame-options: SAMEORIGIN, x-content-type-options: nosniff}
I/flutter ( 8233): BODY
I/flutter ( 8233):   {"blob":{"id":441203,"uid":"d1478e01ebab46278ecee38fd8ac397a00","content_type":"image/jpeg","name":"image_picker2824613439700838070.jpg","size":null,"c
reated_at":"2020-11-13T09:48:16Z","updated_at":"2020-11-13T09:48:16Z","blob_status":null,"set_completed_at":null,"public":false,"account_id":4678,"app_id":3679,"blob_object
_access":{"id":441203,"blob_id":441203,"expires":"2020-11-13T10:48:16Z","object_access_type":"Write","params":"https://s3.amazonaws.com/cb-shared-s3?Content-Type=image%2Fjp
eg\u0026Expires=Fri%2C%2013%20Nov%202020%2010%3A48%3A16%20GMT\u0026acl=authenticated-read\u0026key=d1478e01ebab46278ecee38fd8ac397a00\u0026policy=eyJleHBpcmF0aW9uIjoiMjAyMC
0xMS0xM1QxMDo0ODoxNloiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJjYi1zaGFyZWQtczMifSx7ImFjbCI6ImF1dGhlbnRpY2F0ZWQtcmVhZCJ9LHsiQ29udGVudC1UeXBlIjoiaW1hZ2UvanBlZyJ9LHsic3VjY2Vzc19hY3
Rpb25fc3RhdHVzIjoiMjAxIn0seyJFeHBpcmVzIjoiRnJpLCAxMyBOb3YgMjAyMCAxMDo0ODoxNiBHTVQifSx7ImtleSI6ImQxNDc4ZTAxZWJhYjQ2Mjc4ZWNlZTM4ZmQ4YWMzOTdhMDAifSx7IngtYW16LWNyZWRlbnRpYWwiOi
JBS0lBSUcz
I/flutter ( 8233):
I/flutter ( 8233): CB-SDK: : =========================================================
I/flutter ( 8233): === REQUEST ==== AMAZON === 5cf08e01-8555-4c7f-8519-89fbd3456e7b ===
I/flutter ( 8233): REQUEST
I/flutter ( 8233):   POST https://s3.amazonaws.com/cb-shared-s3
I/flutter ( 8233): HEADERS
I/flutter ( 8233):   {}
I/flutter ( 8233): FIELDS
I/flutter ( 8233):   {Content-Type: image/jpeg, Expires: Fri, 13 Nov 2020 10:48:16 GMT, acl: authenticated-read, key: d1478e01ebab46278ecee38fd8ac397a00, policy: eyJleHBpcm
F0aW9uIjoiMjAyMC0xMS0xM1QxMDo0ODoxNloiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJjYi1zaGFyZWQtczMifSx7ImFjbCI6ImF1dGhlbnRpY2F0ZWQtcmVhZCJ9LHsiQ29udGVudC1UeXBlIjoiaW1hZ2UvanBlZyJ9LH
sic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn0seyJFeHBpcmVzIjoiRnJpLCAxMyBOb3YgMjAyMCAxMDo0ODoxNiBHTVQifSx7ImtleSI6ImQxNDc4ZTAxZWJhYjQ2Mjc4ZWNlZTM4ZmQ4YWMzOTdhMDAifSx7IngtYW16LW
NyZWRlbnRpYWwiOiJBS0lBSUczV1BUN1JBTFlPWlc2US8yMDIwMTExMy91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJ4LWFtei1hbGdvcml0aG0iOiJBV1M0LUhNQUMtU0hBMjU2In0seyJ4LWFtei1kYXRlIjoiMjAyMD
ExMTNUMDk0ODE2WiJ9XX0=, success_action_status: 201, x-amz-algorithm: AWS4-HMAC-SHA256, x-amz-credential: AKIAIG3WPT7RALYOZW6Q/20201113/us-east-1/s3/aws4_request, x-amz-date
: 20201113T094816Z, x-amz-signature: c6ab01cb0787fec157cf5341ab02d75f7f84e4bdec1439cf1eeabf48432a5852}
I/flutter ( 8233):
I/flutter ( 8233): CB-SDK: : *********************************************************
I/flutter ( 8233): *** RESPONSE *** AMAZON *** 201 *** 5cf08e01-8555-4c7f-8519-89fbd3456e7b ***
I/flutter ( 8233): HEADERS
I/flutter ( 8233):   {location: https://s3.amazonaws.com/cb-shared-s3/d1478e01ebab46278ecee38fd8ac397a00, date: Fri, 13 Nov 2020 09:48:18 GMT, content-length: 282, etag: "8
6abf171f74219bd6f0a796be68c15ba", x-amz-request-id: 2BE5D866B991DE17, content-type: application/xml, x-amz-id-2: aNvBhPNhosTK+uuI4BIht7i0oAnNDshuQQqakMrMtnymMtEusolDYmhU5Q5
Ar4s1TqFokPDtURU=, server: AmazonS3}
I/flutter ( 8233): RESPONSE
I/flutter ( 8233):   <?xml version="1.0" encoding="UTF-8"?>
I/flutter ( 8233): <PostResponse><Location>https://s3.amazonaws.com/cb-shared-s3/d1478e01ebab46278ecee38fd8ac397a00</Location><Bucket>cb-shared-s3</Bucket><Key>d1478e01ebab
46278ecee38fd8ac397a00</Key><ETag>"86abf171f74219bd6f0a796be68c15ba"</ETag></PostResponse>
I/flutter ( 8233):
I/flutter ( 8233): CB-SDK: : =========================================================
I/flutter ( 8233): === REQUEST ==== 2157f078-4f8b-4a0a-b555-046a61549403 ===
I/flutter ( 8233): REQUEST
I/flutter ( 8233):   POST https://api.connectycube.com/blobs/441203/complete
I/flutter ( 8233): HEADERS
I/flutter ( 8233):   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 0.5.1, CB-Token: c2cc2f49ccda3e3db818d02b1a9255e5da000e5f}
I/flutter ( 8233): BODY
I/flutter ( 8233):   {"blob":{"size":242312}}
I/flutter ( 8233):
I/flutter ( 8233): sending: <r xmlns="urn:xmpp:sm:3"/>
I/flutter ( 8233): response: <a xmlns='urn:xmpp:sm:3' h='5'/>
I/flutter ( 8233): !!!!handle response <xmpp_stone><a xmlns='urn:xmpp:sm:3' h='5'/></xmpp_stone>
I/flutter ( 8233): !!!!!!! PARSED<xmpp_stone><a xmlns='urn:xmpp:sm:3' h='5'/></xmpp_stone>
I/flutter ( 8233): CB-SDK: : *********************************************************
I/flutter ( 8233): *** RESPONSE *** 200 *** 2157f078-4f8b-4a0a-b555-046a61549403 ***
I/flutter ( 8233): HEADERS
I/flutter ( 8233):   {connection: keep-alive, cache-control: no-cache, set-cookie: _mkra_ctxt=5ed9b8623ea6c86eed999d9ce35bbd3a--200; path=/; max-age=5; HttpOnly; secure, st
atus: 200 OK, transfer-encoding: chunked, date: Fri, 13 Nov 2020 09:48:19 GMT, access-control-allow-origin: *, strict-transport-security: max-age=31536000,max-age=15768000;
, content-type: text/plain; charset=utf-8, x-xss-protection: 1; mode=block, server: nginx/1.16.1, x-request-id: 61811dbd-937a-4738-911f-5c651a746670, cb-token-expirationdat
e: 2020-11-13 11:47:54 UTC, connectycube-rest-api-version: 0.1.1, x-runtime: 0.085220, x-frame-options: SAMEORIGIN, x-content-type-options: nosniff}
I/flutter ( 8233): BODY
I/flutter ( 8233):
I/flutter ( 8233):
I/flutter ( 8233): URl video = https://api.connectycube.com/blobs/d1478e01ebab46278ecee38fd8ac397a00?token=c2cc2f49ccda3e3db818d02b1a9255e5da000e5f
I/flutter ( 8233): CB-SDK: : onSendMessage message= {_id: 5fae56659c5e9a4302fa0754, chat_dialog_id: null, message: Attachment, date_sent: 0, sender_id: null, recipient_id:
null, read_ids: null, delivered_ids: null, views_count: null, attachments: [{id: null, uid: d1478e01ebab46278ecee38fd8ac397a00, type: video, url: https://api.connectycube.c
om/blobs/d1478e01ebab46278ecee38fd8ac397a00?token=c2cc2f49ccda3e3db818d02b1a9255e5da000e5f, content-type: null, size: null, name: null, data: null, width: null, height: nul
l, duration: null}], id: null, created_at: null, updated_at: null}
I/flutter ( 8233): sending: <message id="5fae56659c5e9a4302fa0754" type="chat" to="2636946-3679@chat.connectycube.com">
I/flutter ( 8233):   <body>Attachment</body>
I/flutter ( 8233):   <extraParams xmlns="jabber:client">
I/flutter ( 8233):     <date_sent>1605260901980</date_sent>
I/flutter ( 8233):     <save_to_history>1</save_to_history>
I/flutter ( 8233):     <dialog_id>5fab93d2ca8bf4445d0f327d</dialog_id>
I/flutter ( 8233):     <attachment uid="d1478e01ebab46278ecee38fd8ac397a00" type="video" url="https://api.connectycube.com/blobs/d1478e01ebab46278ecee38fd8ac397a00?token=c2
cc2f49ccda3e3db818d02b1a9255e5da000e5f"/>
I/flutter ( 8233):   </extraParams>
I/flutter ( 8233):   <markable xmlns="urn:xmpp:chat-markers:0"/>
I/flutter ( 8233): </message>
I/flutter ( 8233): sending: <r xmlns="urn:xmpp:sm:3"/>
I/flutter ( 8233): response: <a xmlns='urn:xmpp:sm:3' h='6'/>
I/flutter ( 8233): !!!!handle response <xmpp_stone><a xmlns='urn:xmpp:sm:3' h='6'/></xmpp_stone>
I/flutter ( 8233): !!!!!!! PARSED<xmpp_stone><a xmlns='urn:xmpp:sm:3' h='6'/></xmpp_stone>
I/flutter ( 8233): Delivered: 5fae56659c5e9a4302fa0754
I/flutter ( 8233): sending: <r xmlns="urn:xmpp:sm:3"/>

@Significantinfotech2020
Copy link
Author

In public url I get error. Below is public url log.

I/flutter ( 8233):   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 0.5.1, CB-Token: 75434b1afcd10684ff39254404e50582b6000e5f}
I/flutter ( 8233): BODY
I/flutter ( 8233):   {"blob":{"size":242312}}
I/flutter ( 8233):
I/flutter ( 8233): CB-SDK: : *********************************************************
I/flutter ( 8233): *** RESPONSE *** 200 *** 58e71fe2-05b6-4830-a413-34bc30ac65df ***
I/flutter ( 8233): HEADERS
I/flutter ( 8233):   {connection: keep-alive, cache-control: no-cache, set-cookie: _mkra_ctxt=92d67a432fd878574df8276f94bb9c3c--200; path=/; max-age=5; HttpOnly; secure, st
atus: 200 OK, transfer-encoding: chunked, date: Fri, 13 Nov 2020 09:56:19 GMT, access-control-allow-origin: *, strict-transport-security: max-age=31536000,max-age=15768000;
, content-type: text/plain; charset=utf-8, x-xss-protection: 1; mode=block, server: nginx/1.16.1, x-request-id: 9dd630a4-7d0f-46bb-8410-3ed742e1f3bb, cb-token-expirationdat
e: 2020-11-13 11:55:50 UTC, connectycube-rest-api-version: 0.1.1, x-runtime: 0.083116, x-frame-options: SAMEORIGIN, x-content-type-options: nosniff}
I/flutter ( 8233): BODY
I/flutter ( 8233):
I/flutter ( 8233):
I/flutter ( 8233): URl video = null
I/flutter ( 8233): CB-SDK: : onSendMessage message= {_id: 5fae58450a476bf6b8c2db7c, chat_dialog_id: null, message: Attachment, date_sent: 0, sender_id: null, recipient_id:
null, read_ids: null, delivered_ids: null, views_count: null, attachments: [{id: null, uid: 5b50ee35147946e5b3103257d951b24400, type: video, url: null, content-type: null,
size: null, name: null, data: null, width: null, height: null, duration: null}], id: null, created_at: null, updated_at: null}
I/flutter ( 8233): sending: <message id="5fae58450a476bf6b8c2db7c" type="chat" to="2636388-3679@chat.connectycube.com">
I/flutter ( 8233):   <body>Attachment</body>
I/flutter ( 8233):   <extraParams xmlns="jabber:client">
I/flutter ( 8233):     <date_sent>1605261381790</date_sent>
I/flutter ( 8233):     <save_to_history>1</save_to_history>
I/flutter ( 8233):     <dialog_id>5faba29fca8bf4445d0f4263</dialog_id>
I/flutter ( 8233):     <attachment uid="5b50ee35147946e5b3103257d951b24400" type="video"/>
I/flutter ( 8233):   </extraParams>
I/flutter ( 8233):   <markable xmlns="urn:xmpp:chat-markers:0"/>
I/flutter ( 8233): </message>
I/flutter ( 8233): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 8233): The following assertion was thrown building:
I/flutter ( 8233): 'package:cached_network_image/src/cached_image_widget.dart': Failed assertion: line 205 pos 16:
I/flutter ( 8233): 'imageUrl != null': is not true.
I/flutter ( 8233):
I/flutter ( 8233): When the exception was thrown, this was the stack:
I/flutter ( 8233): #2      new CachedNetworkImage (package:cached_network_image/src/cached_image_widget.dart:205:16)
I/flutter ( 8233): #3      ChatScreenState.buildItem (package:chatconnectycubesdk/chat_dialog_screen.dart:509:33)
I/flutter ( 8233): #4      ChatScreenState.buildListMessage.getWidgetMessages.<anonymous closure> (package:chatconnectycubesdk/chat_dialog_screen.dart:847:42)
I/flutter ( 8233): #5      SliverChildBuilderDelegate.build (package:flutter/src/widgets/sliver.dart:453:22)
I/flutter ( 8233): #6      SliverMultiBoxAdaptorElement._build (package:flutter/src/widgets/sliver.dart:1135:28)
I/flutter ( 8233): #7      SliverMultiBoxAdaptorElement.performRebuild.processElement (package:flutter/src/widgets/sliver.dart:1081:67)
I/flutter ( 8233): #8      Iterable.forEach (dart:core/iterable.dart:283:30)
I/flutter ( 8233): #9      SliverMultiBoxAdaptorElement.performRebuild (package:flutter/src/widgets/sliver.dart:1121:24)
I/flutter ( 8233): #10     SliverMultiBoxAdaptorElement.update (package:flutter/src/widgets/sliver.dart:1060:7)
I/flutter ( 8233): #11     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #12     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #13     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #14     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5693:32)
I/flutter ( 8233): #15     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6293:17)
I/flutter ( 8233): #16     _ViewportElement.update (package:flutter/src/widgets/viewport.dart:228:11)
I/flutter ( 8233): #17     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #18     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #19     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #20     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #22     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #23     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #24     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #25     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #26     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #27     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4847:11)
I/flutter ( 8233): #28     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #29     StatefulElement.update (package:flutter/src/widgets/framework.dart:4879:5)
I/flutter ( 8233): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #31     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #32     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #33     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #34     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #35     ProxyElement.update (package:flutter/src/widgets/framework.dart:5033:5)
I/flutter ( 8233): #36     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #37     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #38     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #39     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #40     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #41     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #42     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #43     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
I/flutter ( 8233): #44     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #45     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #46     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #47     StatelessElement.update (package:flutter/src/widgets/framework.dart:4756:5)
I/flutter ( 8233): #48     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #49     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #50     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4847:11)
I/flutter ( 8233): #51     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #52     StatefulElement.update (package:flutter/src/widgets/framework.dart:4879:5)
I/flutter ( 8233): #53     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #54     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #55     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4847:11)
I/flutter ( 8233): #56     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #57     StatefulElement.update (package:flutter/src/widgets/framework.dart:4879:5)
I/flutter ( 8233): #58     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #59     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #60     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #61     StatelessElement.update (package:flutter/src/widgets/framework.dart:4756:5)
I/flutter ( 8233): #62     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #63     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #64     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #65     ProxyElement.update (package:flutter/src/widgets/framework.dart:5033:5)
I/flutter ( 8233): #66     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #67     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5693:32)
I/flutter ( 8233): #68     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6293:17)
I/flutter ( 8233): #69     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #70     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5693:32)
I/flutter ( 8233): #71     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6293:17)
I/flutter ( 8233): #72     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #73     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #74     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4847:11)
I/flutter ( 8233): #75     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #76     StatefulElement.update (package:flutter/src/widgets/framework.dart:4879:5)
I/flutter ( 8233): #77     Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
I/flutter ( 8233): #78     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
I/flutter ( 8233): #79     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4847:11)
I/flutter ( 8233): #80     Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
I/flutter ( 8233): #81     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2777:33)
I/flutter ( 8233): #82     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:906:21)
I/flutter ( 8233): #83     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:309:5)
I/flutter ( 8233): #84     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
I/flutter ( 8233): #85     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9)
I/flutter ( 8233): #86     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:971:5)
I/flutter ( 8233): #90     _invoke (dart:ui/hooks.dart:251:10)
I/flutter ( 8233): #91     _drawFrame (dart:ui/hooks.dart:209:3)
I/flutter ( 8233): (elided 5 frames from class _AssertionError and dart:async)
I/flutter ( 8233): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 8233): Another exception was thrown: Exception: Invalid image data
I/flutter ( 8233): sending: <r xmlns="urn:xmpp:sm:3"/>

@TatankaConCube
Copy link
Contributor

but in your example you are uploading an image "content_type":"image/jpeg","name":"image_picker2824613439700838070.jpg"

is it correct?

@Significantinfotech2020
Copy link
Author

but in your example you are uploading an image "content_type":"image/jpeg","name":"image_picker2824613439700838070.jpg"

is it correct?

No, I am uploading video. but In chat list, image was displayed not video.

In dashboard, [{"uid":"794d1d6358b3414ebc47f23132b1691000","type":"video","url":"https://api.connectycube.com/blobs/794d1d6358b3414ebc47f23132b1691000?token=31a8da0992023c56e1fd54a5d03dec6e7c000e5f"}]

this log displayed in Attachments.

@TatankaConCube
Copy link
Contributor

no, it is about attachment, which you set manually, but for upload you set this config "content_type":"image/jpeg","name":"image_picker2824613439700838070.jpg"

from another side, 242 kb it too small size for video

note: I'm not sure, that cached_network_image plugin can work with videos, I think you should search for another solution for video attachments.

@Significantinfotech2020
Copy link
Author

no, it is about attachment, which you set manually, but for upload you set this config "content_type":"image/jpeg","name":"image_picker2824613439700838070.jpg"

from another side, 242 kb it too small size for video

note: I'm not sure, that cached_network_image plugin can work with videos, I think you should search for another solution for video attachments.

If you have idea how to work with video sharing then suggest I will try.

@TatankaConCube
Copy link
Contributor

I didn't investigate this feature yet, sorry, I can't help with this now.

@Significantinfotech2020
Copy link
Author

Significantinfotech2020 commented Dec 7, 2020

Hello @TatankaConCube

Did you got any thing for sharing video in messaging. I tried with this, but it did not work for me. If you got any solution then please suggest me.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

Please give me reply asap for above difficulty.

@TatankaConCube
Copy link
Contributor

I tried with this, but it did not work for me.

which issues do you have? There are issues with Connectycube API or with your Flutter project? If it is problem with Connectycube API, sure, we will help you to resolve it.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

which issues do you have?

I have issue while I share Video file or any other file.

There are issues with Connectycube API or with your Flutter project?

Probably, I think this issue is with Connectycube API, because video is uploaded on dashboard, when I copy that uploaded link from dash board, it does not load video and I see white border square box in the middle screen and in the chat page I see error image rather than any other file such as video, audio, and etc.

If it is problem with Connectycube API, sure, we will help you to resolve it.

We already discussed this issue on above comment. Now, If you got any solution for this then suggest me asap.

@TatankaConCube
Copy link
Contributor

First of all, we should understand, did you correctly upload the file to storage? As I noted before, you uploaded a video file as a picture and it is a mistake(I mean this message), need to fix it.

@Significantinfotech2020
Copy link
Author

First of all, we should understand, did you correctly upload the file to storage?

I can see this type of message in dashboard chat attachment.

[{"id":"13541682","uid":"fb6fe45b0cd84d3293dae1357b871ea200","type":"video","url":"https://api.connectycube.com/blobs/fb6fe45b0cd84d3293dae1357b871ea200?token=26c0f7566694d95b8055bb44f0cf1287bd000e5f"}]

As I noted before, you uploaded a video file as a picture and it is a mistake(I mean this message), need to fix it.

Yes, Exactly.

@TatankaConCube
Copy link
Contributor

It just attachment data, but not the data of the uploaded file, please check, which configs you set for uploading the file. You have to change them according to the type of file, which you upload to storage. If it works for pictures, it should work for video too.

@Significantinfotech2020
Copy link
Author

It just attachment data, but not the data of the uploaded file, please check, which configs you set for uploading the file. You have to change them according to the type of file, which you upload to storage. If it works for pictures, it should work for video too.

I used this method for uploading method

--> select video from Gallery

void openVideoGallery() async {
    final pickedFile = await picker.getVideo(source: ImageSource.gallery);
    if (pickedFile == null) return;
    setState(() {
      isLoading = true;
    });
    file = File(pickedFile.path);
    uploadVideo();
  }

--> Upload Video

Future uploadVideo() async {
    uploadFile(file).then((cubeFile) {
      CubeMessage message = CubeMessage();
      var url = cubeFile.getPrivateUrl();
      print('URl video = ${cubeFile.getPrivateUrl()}');
      message.body = 'Attachment';
      message.saveToHistory = true;
      message.markable = true;

      CubeAttachment attachment = CubeAttachment();
      attachment.uid = cubeFile.uid;
      attachment.id = file.hashCode.toString();
      attachment.type = CubeAttachmentType.VIDEO_TYPE;
      pref.setString('videoType', attachment.type);
      print('getAttachmentType: ' + pref.getString('videoType'));
      attachment.url = url;
      message.attachments = [attachment];
      return onSendMessage(message);
    }).catchError((error) {});
  }

--> Send Message

void onSendMessage(CubeMessage message) async {
    log("onSendMessage message= $message");
    ChatMessagesManager chatMessagesManager =
        CubeChatConnection.instance.chatMessagesManager;
    textEditingController.clear();
    await _cubeDialog.sendMessage(message);
    message.senderId = _cubeUser.id;
    addMessageToListView(message);
    listScrollController.animateTo(0.0,
        duration: Duration(milliseconds: 300), curve: Curves.easeOut);
  }

--> Receive Message

void onReceiveMessage(CubeMessage message) {
    ChatMessagesManager chatMessagesManager =
        CubeChatConnection.instance.chatMessagesManager;
    log("onReceiveMessage message= $message");
    if (message.dialogId != _cubeDialog.dialogId ||
        message.senderId == _cubeUser.id) return;

    chatMessagesManager.chatMessagesStream.listen((incomingMessage) {
      String attachmentUid = incomingMessage.attachments?.first?.uid;
      if (attachmentUid != null) {
        attachmentUrl = getPrivateUrlForUid(attachmentUid);
        print('attachmentURL: ' + attachmentUrl);
      }
    });
  }

Now, Suggest me, in which config I have to upload video file.

@TatankaConCube
Copy link
Contributor

hmm... looks like image_picker plugin returns a path with the wrong file extension, you can try this workaround:

imageFile = File(pickedFile.path);
imageFile = await imageFile.rename(pickedFile.path.replaceFirst(".jpg", ".mp4"));

it correct loads file, and you can watch this file by link, but the better way will be found a plugin, which will return the correct path to the file.

@Significantinfotech2020
Copy link
Author

Significantinfotech2020 commented Dec 8, 2020

@TatankaConCube

imageFile = File(pickedFile.path);
imageFile = await imageFile.rename(pickedFile.path.replaceFirst(".jpg", ".mp4"));

This is not working. It throws error while I pick file and upload on dashboard. So, it is not working.

it correct loads file, and you can watch this file by link, but the better way will be found a plugin, which will return the correct path to the file.

I tried file_picker package but when after adding this package, application does not build because of this package. So, this is also not working. If you have any idea for selecting file package, then please help me.

When I use file_picker package, this error displays in terminal.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     D:\Jaimin\chat_connectycube_sdk\build\file_picker\intermediates\library_manifest\debug\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found i
n <manifest>.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 37s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        39.2s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin device_id...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                   11.4s
         *********************************************************
WARNING: This version of device_id will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://goo.gl/CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'device_id'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s


Exception: The plugin device_id could not be built due to the issue above.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

Please reply me asap.

@TatankaConCube
Copy link
Contributor

please read the documentation for this plugin and do required changes https://github.com/miguelpruivo/flutter_file_picker/wiki/Troubleshooting#-issue-1

@TatankaConCube
Copy link
Contributor

It throws same error.

which error do you mean?
yesterday I tried to upload the video file and get it by link. I'm sure, it is not a Connectycube API issue. The main requirement for the file for uploading is the correct file name with the correct extension.

@Significantinfotech2020
Copy link
Author

which error do you mean?

It is image file extension error.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

Which Plugin did you for selecting video? How you call it in the code?

@TatankaConCube
Copy link
Contributor

I did it via file renaming, as I said before. As a result, the file was uploaded successfully and I open it by the link in Chrome and the video played successfully.

@Significantinfotech2020
Copy link
Author

I set this as you said earlier, but I got error.

--> I use this method on image icon click.

void _settingModalBottomSheet(context) {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext bc) {
          return Container(
            child: new Wrap(
              children: <Widget>[
                new ListTile(
                    leading: new Icon(Icons.photo),
                    title: new Text('Image'),
                    onTap: () {
                      Navigator.pop(context);
                      openGallery();
                    }),
                new ListTile(
                  leading: new Icon(Icons.videocam),
                  title: new Text('Video'),
                  onTap: () {
                    Navigator.pop(context);
                    openVideoGallery();
                  },
                ),
              ],
            ),
          );
        });
  }

--> This is openGallery() method.

 void openGallery() async {
    final pickedFile = await picker.getImage(source: ImageSource.gallery);
    if (pickedFile == null) return;
    setState(() {
      isLoading = true;
    });
    imageFile = File(pickedFile.path);
      uploadImageFile();
  }

--> This is openVideoGallery() method.

 File file;

  void openVideoGallery() async {
    final pickedFile = await picker.getVideo(source: ImageSource.gallery);
    if (pickedFile == null) return;
    setState(() {
      isLoading = true;
    });
    file = File(pickedFile.path);
    print('videofile: ' +  File(pickedFile.path).toString());
   imageFile =
       await imageFile.rename(pickedFile.path.replaceFirst(".jpg", ".mp4"));
    uploadVideo();
  }

--> When this bottom sheet opens, it display two options like image and video. When I pressed on image button, image send successfully, but when I clicked on video button, it displays error icon from CachedNetworkImage and display log which I put below.

[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method 'rename' was called on null.
E/flutter (30342): Receiver: null
E/flutter (30342): Tried calling: rename("/data/user/0/com.example.chatconnectycubesdk/cache/image_picker3240110775622862252.mp4")

and video does not upload on dashboard.

If you find my mistake then please suggest me.

@TatankaConCube
Copy link
Contributor

you created file = File(pickedFile.path); but tried rename imageFile why?
you should rename your created file, like

file = await file.rename(pickedFile.path.replaceFirst(".jpg", ".mp4"));

and use this file for method uploadVideo();

@Significantinfotech2020
Copy link
Author

Thank you. It's working.

@Significantinfotech2020
Copy link
Author

@TatankaConCube

Now, I want to set loader till video does not load completely, So How can I set this?

I mean, can I get downloading progress using ConnectyCube_SDK?

@TatankaConCube
Copy link
Contributor

in the current realization of our SDK, we don't provide a callback with progress.

@TatankaConCube
Copy link
Contributor

hello @Significantinfotech2020, today we released the new version of our SDK, now it has the function uploadFileWithProgress which provides the possibility for listening progress of the file uploading process.

If the issue was resolved, please close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants