Upload video into SQLite

后端 未结 4 749
眼角桃花
眼角桃花 2020-12-11 12:43

Is it possible to upload a video into an SQLite DB (not just the URL)? I have tried it but have not found success; if any one knows the solution, please post the answer.

相关标签:
4条回答
  • 2020-12-11 13:05

    It won't be the exact answer for this question. But I would like to give solution. You can save the video in documents directory as a file format. And insert the file name in your SQLITE database.

    And whenever you want to access the video, you can do easily by querying the file name.

    As SQLITE is a low-weight database & thus it won't be recommended to add heavy load on it.

    0 讨论(0)
  • 2020-12-11 13:14

    It sounds like a bad idea to store big files in a SQL database, especially SQLite. If you really need to do it, make sure to use a BLOB column and to escape your data correctly.

    0 讨论(0)
  • 2020-12-11 13:18

    It is a really bad practice to try to store large binary data in a database, you are much better off storing the video on the phone and the location of the video in the database. This will drastically improve your speed in opening the file since a file lookup on the iPhone is much faster than pulling all of those bytes from the database.

    0 讨论(0)
  • 2020-12-11 13:20
    NSData *imgData;
    imgData = [[NSData alloc] initWithContentsOfURL:
                      [NSURL URLWithString:[aDict objectForKey:@"Icon"]]];
    if (sqlite3_prepare_v2(database, sqlStatement1, -1, 
                           &compiledStatement1, NULL) == SQLITE_OK) 
    {
        sqlite3_bind_blob(compiledStatement1, 1, [imgData bytes], 
                          [imgData length], SQLITE_TRANSIENT);
    }
    
    if ([[aDict objectForKey:@"Icon"] length] > 0)
    {
        [imgData release];
    }
    
    0 讨论(0)
提交回复
热议问题