Start a new topic
Answered

Unable to Download and View Video

After successfully uploading a video to the FileStore, I then try to download and view the video using the following code:   

        let fileStore = FileStore.getInstance()
        let myFile = File()
        myFile.fileId = "<my uploaded file ID>" 

        fileStore.download(myFile) { (file, url: URL?, error) in
            
            if(error != nil) {
                print(error)
            }
            
            if file != nil {
                //success
                print("File: \(file?.download)")
                self.videoUrl = (file?.download!)!
            } else {
                //fail
            }
        } 

  

However, the error  is not nil and returns "Invalid response from the server".

The file object is returned with the correct data (i.e. acl, filename, download URL, etc.), but the url returned is nil.


I tried to view the file.download value (which contains https://storage.googleapis.com/ed9ddfc......) in my app's AVKit Player View Controller, but the video is not loaded or viewable.  (Note that I have made sure my code and the video player works by loading an external video on a test server.)


Any suggestions or help with this? The ability to upload, download, and view videos is the core feature of our company's app, so it is important that we have this working.


Thanks!



Best Answer
Chris,

Word from engineering as follows:

You need to specify the correct mime type of the video in order to AVKit Player to play the video correctly. Please see the code snippet below:

 

let file = File()
file.mimeType = "video/mp4"
fileStore.upload(file, path: url.path) { file, error in
}

 


Let me know if this helps.

Thanks,
Pranav
Kinvey

 



Answer
Chris,

Word from engineering as follows:

You need to specify the correct mime type of the video in order to AVKit Player to play the video correctly. Please see the code snippet below:

 

let file = File()
file.mimeType = "video/mp4"
fileStore.upload(file, path: url.path) { file, error in
}

 


Let me know if this helps.

Thanks,
Pranav
Kinvey

 


Hi Pranav,


I was able to finally figure out the issue.  The problem was that the video I was updating wasn't always completed or the URL specified for the video file was empty.  Calling the save function on the SDK, regardless if the video file was empty or incomplete, the function returned a successful (200) response.  This lead me to believe the upload has completed successfully.


In my opinion, I think the SDK (and service endpoint) should be updated so that it returns an error if the file path of a video/image is empty or the upload doesn't complete.


Thanks.

Chris,

I haven't heard anything back from engineering yet and will get back to you once I have more information from them.

 

Thanks,

Pranav

Kinvey

Hi Pranav J,


I've been doing some testing regarding the uploading and downloading/viewing of videos.


First, I upload a video using the iOS Kinvey SDK. That completed successfully and I am able to see the record in the "Files" data tab in the Kinvey Console.


Next, I use Postman to make REST API requests to get the download URL. The request completes successfully as you can see form the 200 response below:


image


Lastly, I use the _downloadURL which contains the Google Cloud link to download and view the vide, but get a 400 response with the following error:


image



Note that this is happening with all vide files that I upload using the iOS Kinvey SDK on a real iPhone 5s device.

Chris,

I have escalated this to engineering and will get back to you once I have more information from them.

Thanks,
Pranav
Kinvey
MLIBZ-1635

 

Hi Pranav,


1.  It is happening on 100% of the videos I upload.  Once I upload, I am not able to download or view the video using the File.download URL.

2.  We have no image files, we only want to upload and download/view videos.

3. The test videos are around 2MB.  But in production, we expect them to be up to 100 MB.


If it helps, I've been testing on a real iPhone 5S device running 9.2.1


Thanks,

Chris

Chris,

  1. Do you see this consistently?
  2. Do you have any image files and are you able to download them?
  3. What is the size of the video file you are trying to download?

Thanks,
Pranav
Kinvey

 

Login or Signup to post a comment