Exemplo n.º 1
0
// The finaly step: write _data to tempfile and move it to neW_url
static KIO::CopyJob *pasteDataAsyncTo(const KURL &new_url, const QByteArray &_data)
{
    KTempFile tempFile;
    tempFile.dataStream()->writeRawBytes(_data.data(), _data.size());
    tempFile.close();

    KURL orig_url;
    orig_url.setPath(tempFile.name());

    return KIO::move(orig_url, new_url);
}
Exemplo n.º 2
0
KIO_EXPORT void KIO::pasteData(const KURL &u, const QByteArray &_data)
{
    KURL new_url = getNewFileName(u, QString::null);
    // We could use KIO::put here, but that would require a class
    // for the slotData call. With NetAccess, we can do a synchronous call.

    if(new_url.isEmpty())
        return;

    KTempFile tempFile;
    tempFile.setAutoDelete(true);
    tempFile.dataStream()->writeRawBytes(_data.data(), _data.size());
    tempFile.close();

    (void)KIO::NetAccess::upload(tempFile.name(), new_url, 0);
}